I have a existing project say A which has dependencies over a few projects. Now I want to make this project A as a library project for Project B. What I have done so far is in the build.gradle of Project A, I have changed the plugin from "android:application" to "android:library", My question is how to use the project A as a library module to Project B. When i add a new Module and give its dependency to Project A the build files are not generated in the new module. If a create a new Project for B and then import Project A as a module i get errors on the dependencies used for Project A. Please suggest how to go about.
Edit build.gradle
of your module (not the root build.gradle).
Replace apply plugin: 'com.android.application'
with apply plugin: 'com.android.library'
.
Remove applicationId
from the same build.gradle project as described below:
defaultConfig {
applicationId "com.example.packageName"//remove this line
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
After this sync your gradle file. Now your project has been marked as library, but to create a release version of library you need to use this library into a module, so we will create a new module in the same project.
For creating new module go to:
File-> New Module-> (choose)phone and tablet Application->next...
Let's say the new module created is B. Now add dependency of library A on module B as described by user @Sam Rad here.
Run your project, after succesfull Run you will find a release version of library in folder
A->build->outputs-> (.aar package Release version)
Hope this will help