Please note this project compiled successfully before upgrading to Android Studio 3.1, Gradle build tools 3.1.0 and Gradle Wrapper 4.4.
The exception occurs during the Gradle task transformClassesAndResourcesWithPrepareIntermediateJarsForSomethingDebug:
Caused by: java.util.zip.ZipException: duplicate entry: com/me/utils/model/singleModel/NodeModel.class
Please note that the exception only occurs on Kotlin classes (like NodeModel above). If I remove this class, the exception will occur on the very next Kotlin class.
All of the other questions on SO that mention this exception were somehow related to duplicate third party libraries from within project dependencies. This is however not my case, as NodeModel is a custom class that I wrote myself. It's actually just a simple Kotlin data class.
The project is using Kotlin version 1.2.30, build tools 27.0.3, support library 27.1.0 and Firebase 12.0.1.
I have tried cleaning and rebuilding the project several times, changing between my local JDK and the embedded one, nothing works.
I tried running Gradle with --stacktrace --debug in order to find out where is the duplicate coming from, but the Gradle logs did not mention anything relevant.
Updated answer
Even with the workaround mentioned below, I was still getting the occasional exception. Now that Android Studio 3.1.1 has been released, the issue has disappeared completely. Just make sure to also update to version 3.1.1 of the Gradle build tools, and at least version 4.4 of the Gradle wrapper:
In gradle-wrapper.properties
:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
In the project's build.gradle
:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
...
}
}
Initial answer
Increasing the Gradle Wrapper version to 4.6 fixed it for me, but only temporarily. The exception occured again the next day.
The only working solution I found so far is to downgrade the Gradle Wrapper back to 4.3.1, and the Gradle build tools to 3.0.0, until a new stable version of the Gradle build tools is available.
In gradle-wrapper.properties
:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
In the project's build.gradle
:
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With