Add project dependency on another project in Android studio

I have an existing project that says A, which has dependencies on several 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 changed the plugin from "android: application" to "android: library", My question is is how to use project A as a library module for project B. When I add a new module and give it a dependency on Project A, assembly files are not generated in the new module. If you create a new project for B and then import Project A as a module, I get errors in the dependencies used for Project A. Please suggest how to do this.

+4
source share
1 answer

RE HOW TO CREATE AN EXISTING PROJECT ANDROID STUDIO PROGRAM IN THE LIBRARY

  •   
  • Change build.gradle of your module (not root build.gradle)  
replace apply plugin: 'com.android.application' (with) apply plugin: 'com.android.library'

Remove the application 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 that, synchronize the gradle file. Now your project has been marked as a library, but to create a version of the library version you need to use this library in the module, so we will create a new module in the same project, to create a new module go to

File-> New module-> (select) phone and tablet Application-> next ..... Let the new module be created B.

Now add the library dependency A on module B as described by @Sam Rad #here

http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio

Run the project, after succesfull Run you will find the version version of the library in the folder

1. A->build->outputs-> (.aar package Release version) 

,

+3

All Articles