Open build.gradle your application (inside your application directory) and change:
apply plugin: 'com.android.application'
with
apply plugin: 'com.android.library'
If you have applicationId in build.gradle , delete it:
defaultConfig { applicationId "com.your.application.id" }
then clean up the project and rebuild or just sync your gradle with Android Studio
If you added some additional gradle properties, such as applicationVariants.all , you should replace it with libraryVariants.all and vice versa if you convert the library into an application
If you want to add a new step to your conversion, you can change the name of the "application" module, created by default by Android-Studio with a name more adapted to the library module. You can rename the directory application with <your_module_name> . open the settings.gradle file (in the root of your project) and replace the application with <your_module_name> . Then go to Build> Create Module <your_module_name> , and there you are, your module is renamed.
source share