Reputation: 15090
My project depends on dependency A and dependency B.
Dependency A also depends on dependency B, but a different version of it.
The problem is in project A's build.gradle
dependency B is included as a jar directly using the file and fileTree methods:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/B.jar')
}
My project's build.gradle
looks like this:
dependencies {
compile 'com.B:B:myvesion'
compile('com.A:A:theirversion') {
exclude module: 'B'
}
}
But my build fails with this exception:
Execution failed for task ':myproject:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lcom/B/someclass;
I want to exclude the jar
version of B from my project and use my version. How do I do this? Seems like the exclude
instruction doesn't work in my case.
Upvotes: 2
Views: 2690
Reputation: 364760
You can't do it for the jar files.
You can exclude transitive dependencies (described in the pom file). The jar file is not a transitive dependency.
Upvotes: 6