android
build_error
ai_generated
true
Execution failed for task ':app:transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/collect/ImmutableList.class
ID: android/gradle-task-assemble-debug-failed-jetifier
80%Fix Rate
82%Confidence
1Evidence
2023-08-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Android Gradle Plugin 8.1 | active | — | — | — |
| Gradle 8.2 | active | — | — | — |
| Jetifier 1.0.0-beta10 | active | — | — | — |
| Android Studio Hedgehog 2023.1.1 | active | — | — | — |
Root Cause
Duplicate class found in multiple dependencies, often due to Jetifier converting both support libraries and AndroidX, or two libraries shipping the same class.
generic中文
多个依赖中发现重复类,通常是由于 Jetifier 同时转换了支持库和 AndroidX,或者两个库提供了相同的类。
Official Documentation
https://developer.android.com/studio/build/jetifierWorkarounds
-
85% success Run `./gradlew :app:dependencies --configuration debugCompileClasspath` to identify which libraries bring the duplicate class. Then exclude the transitive dependency in build.gradle: implementation('com.example:library:1.0') { exclude group: 'com.google.guava', module: 'guava' }
Run `./gradlew :app:dependencies --configuration debugCompileClasspath` to identify which libraries bring the duplicate class. Then exclude the transitive dependency in build.gradle: implementation('com.example:library:1.0') { exclude group: 'com.google.guava', module: 'guava' } -
80% success Upgrade all dependencies to their AndroidX versions and disable Jetifier in gradle.properties: android.jetifier.enabled=false
Upgrade all dependencies to their AndroidX versions and disable Jetifier in gradle.properties: android.jetifier.enabled=false
-
75% success Use the `com.google.guava:guava:30.1.1-android` variant which avoids conflicts with other Android libraries.
Use the `com.google.guava:guava:30.1.1-android` variant which avoids conflicts with other Android libraries.
中文步骤
Run `./gradlew :app:dependencies --configuration debugCompileClasspath` to identify which libraries bring the duplicate class. Then exclude the transitive dependency in build.gradle: implementation('com.example:library:1.0') { exclude group: 'com.google.guava', module: 'guava' }Upgrade all dependencies to their AndroidX versions and disable Jetifier in gradle.properties: android.jetifier.enabled=false
Use the `com.google.guava:guava:30.1.1-android` variant which avoids conflicts with other Android libraries.
Dead Ends
Common approaches that don't work:
-
70% fail
Disabling Jetifier entirely may cause other libraries to break if they still depend on support libraries.
-
65% fail
Adding an exclude statement in packagingOptions for the duplicate class often masks the root cause and may remove needed functionality.
-
60% fail
Using a newer version of the dependency without checking its transitive dependencies may introduce more duplicates.