Reputation: 1859
I'm getting the following exception when building my Android app with Gradle:
Execution failed for task ':transformClassesWithJarMergingForGoogleGermanDebugAndroidTest'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/hamcrest/BaseDesc
The problem seems to be that in my build.gradle file I have declared:
testCompile 'org.hamcrest:hamcrest-all:1.3'
androidTestCompile 'org.hamcrest:hamcrest-all:1.3'
However, I need both dependencies for unit tests and integration tests. How to solve this?
Upvotes: 0
Views: 1229
Reputation: 93
buildTypes {
release {
multiDexEnabled true;
}
}
try this this should work
Upvotes: -3
Reputation: 1859
The problem was that another jar (Mockito) included hamcrest-core
as a transitive dependency. This module contains all classes under the package name org.hamcrest.*
. Hence the conflict. The solution was:
configurations {
all*.exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
As described here: https://docs.gradle.org/current/userguide/dependency_management.html Chapter 23.4.7
Upvotes: 4
Reputation: 10009
Try adding the exclude
parameter for repeated entries.
androidTestCompile 'org.hamcrest:hamcrest-all:1.3' {
exclude module: 'BaseDesc'
}
Upvotes: 0