Android gradle build:在父级和子级之间共享库

时间:2015-10-09 14:50:11

标签: android android-studio gradle android-gradle build.gradle

我们有这样的项目结构:

Project
|__build.gradle
|__settings.gradle
|__app (android application)
   |__build.gradle
   |__libA (android library)
   |__libB (android library)
      |__libA (android library)

我的应用取决于libAlibBlibB然而,再次取决于libA。我应该如何构建我的构建,以便applibB共享libA的同一副本?

注意:applibAlibB是从源代码编译的,而不仅仅是jar文件。

1 个答案:

答案 0 :(得分:2)

只需使用:

Project
|__build.gradle
|__settings.gradle
|__app (android application)
   |__build.gradle
|__libA (android library)
   |__build.gradle
|__libB (android library)
   |__build.gradle

settings.gradle

include ':app' , ':libA' , 'libB'

app/build.gradle

dependencies {
    compile project(':libA')
    compile project(':libB')
}

libB/build.gradle

dependencies {
    compile project(':libA')
}