Skip to content Skip to sidebar Skip to footer

Android Studio: Add Project As Library

I want to add this project as library to my project in android studio. this is what I tried, I have my project directory as f:/my project/my app/src and my library in f:/my project

Solution 1:

Edit the settings.gradle file (in directory f:/my project), it must contains something like this:

include'my app','my library'

If this file don't exists: create it manually. The settings.gradle contains the list of gradle modules in a multi-module project.

Then you must add the dependency to your library in app. To do so edit the my app/build.gradle and add this line :

dependencies {
    compile project(':my library')
}

I also notice that you don't use default structure for your projects (i.e. you put the code in src/ instead of src/main/java) so you will have to overwrite some values of the default fileSet in the build.gradle of your projects. Be sure to have something like this in my app/build.gradle and my library/build.gradle :

android {
    sourceSets {
        main {
            java.srcDirs = ['src']
        }
    }
}

Post a Comment for "Android Studio: Add Project As Library"