Learning Android Development

Making Android App A Library Module Instead

An Unconventional Refactor Extraction That Can Be Handy

Photo by Quino Al on Unsplash

In a conventional app refactoring, we usually extract our app code away at the bottom level and maintain the original app module as a top module.

However, in rare moments, it might be handy to extract the code from the top and make the original app module a library.

So, the question is, can an Android App (Application) turn into an app module library?

Below is how it can be achieved.

Modification to the App Module

1. Change the Plugin

When you create an application, the plugin provided is as below

plugins {
id 'com.android.application'

id 'org.jetbrains.kotlin.android'
}

--

--