I am trying to convert an Android Studio project as a library.
What is the best way to do this and the steps I need to follow?
What file can I remove from that library project, so that the library look cleaner?
aar bundle is the binary distribution of an Android Library Project. An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. A AAR file can be included in the build process of an Android application similar to a JAR file.
The main difference is aar is splitted inside android to jar. If your app will be used only in user app only in android studio then aar is preferred. If you are planning for app to communicate with c/c++ compiled lib.so file jar is preferred.
An Android library is structurally the same as an Android app module. It can include everything needed to build an app, including source code, resource files, and an Android manifest. However, instead of compiling into an APK that runs on a device, an Android library compiles into an Android Archive (AAR) file that you can use as a dependency for an Android app module. Unlike JAR files, AAR files can contain Android resources and a manifest file, which allows you to bundle in shared resources like layouts and drawables in addition to Java classes and methods.
Convert an app module to a library module
Open the build.gradle file for the existing app module. At the top, you should see the following:
apply plugin: 'com.android.application'
Change the plugin assignment as shown here:
apply plugin: 'com.android.library'
Also in this file, you have to delete this line
applicationId "your.application.id"
Click Sync Project with Gradle Files.
Check this for more details https://developer.android.com/studio/projects/android-library.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With