Recently, I faced this build error while trying to integrate kotlin in our project.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForPreKitkatDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/intellij/lang/annotations/Identifier.class
As you can see, gradle is trying to add same entry two times, referenced by different dependencies.
So to figure out which are those two dependencies, I built the project with some extra options :
./gradlew assembleDebug --stacktrace --info | grep Identifier.class
This was the output:
addJar(/Users/yashasvi/.gradle/caches/modules-2/files-2.1/com.intellij/annotations/12.0/bbcf6448f6d40abe506e2c83b70a3e8bfd2b4539/annotations-12.0.jar): entry org/intellij/lang/annotations/Identifier.class
addJar(/Users/yashasvi/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar): entry org/intellij/lang/annotations/Identifier.class
As you can see, the culprit here is newly added dependency with group org.jetbrains.
Solution?
It’s simple. Just exclude the appropriate module from one of the dependencies. In my case, the problem was introduced when I was trying to add kotlin-std-lib-jre7 dependency from jetbrains.
So, I changed
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
to
compile ("org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"){
exclude module: 'annotations'
}
Let me know in case of any doubts.
Cheers !
Salvou minha vida. Obrigaddo
ReplyDelete