Android Studio: add project as library

后端 未结 1 864
一生所求
一生所求 2021-01-23 08:05

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 l

相关标签:
1条回答
  • 2021-01-23 08:45

    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']
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题