Android "Duplicate class found" in CI
The same fully qualified class is provided by two dependencies on the classpath. D8 cannot merge them and fails the build.
What this error means
The build fails with Duplicate class com.example.Foo found in modules A and B, often after adding or upgrading a library that bundles a class also pulled in transitively.
gradle
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules
kotlin-stdlib-1.8.0 and kotlin-stdlib-jdk8-1.8.0Common causes
Two artifacts ship the same class
A split or merged library, or two versions of the same library, provide the same class.
Version skew across transitive dependencies
Different versions of related artifacts overlap in the classes they define.
How to fix it
Exclude the redundant module
- Identify the two modules in the error.
- Exclude the redundant one or force a single aligned version.
build.gradle.kts
dependencies {
implementation("com.example:lib:2.0") {
exclude(group = "org.duplicate", module = "old-module")
}
}Align versions with a platform/BOM
Use a BOM or resolution strategy so related artifacts resolve to one consistent version set.
How to prevent it
- Run a dependency report to spot overlaps and use BOMs to keep related libraries aligned. Catch duplicates with a build check before release.
Related guides
Android "Could not resolve com.android.tools.build:gradle" in CIFix the Android "Could not resolve com.android.tools.build:gradle" error in CI by adding the google() reposit…
Android "Manifest merger failed" in CIFix the Android "Manifest merger failed" error in CI by resolving the conflicting attribute or library manife…
Android "minSdk/compileSdk mismatch" in CIFix Android minSdk and compileSdk mismatch errors in CI by raising compileSdk or your dependency requires a h…