I set up the project structure as follows:
buildscript-test-app
|
|
buildscript-test-lib
| \------------------------\
| |
buildscript-test-lib-sub-a buildscript-test-lib-sub-b
Both lib-sub-*
contain assets/foo.txt
with different contents.
build.gradle
of buildscript-test-lib
:
apply plugin: 'com.android.library'
android {
// omitted default config stuff
packagingOptions {
pickFirst 'assets/**'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':buildscript-test-lib-sub-a')
implementation project(':buildscript-test-lib-sub-b')
}
build.gradle
of buildscript-test-app
:
apply plugin: 'com.android.application'
android {
// omitted default config stuff
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':buildscript-test-lib')
}
Gradle always picks the file from buildscript-test-lib-sub-a
regardless of the order of dependencies (presumably because of alphabetic ordering).
Something else in your buildscript must be wrong if this doesn't work. If it doesn't work, can you provide more details on the build.gradle
of your app module and library modules?
Maybe you are overriding pickFirsts
in your app. If that's the case, you should instead of pickFirsts = [somevalue]
do pickFirst += 'foo'
or pickFirst = 'foo'