Skip to content
Latchkey

Android "Duplicate class" in CI

Two dependencies bring the same class onto the classpath, so the Android build cannot decide which to use. Usually an old and a new artifact of the same library (or a renamed module) coexist.

What this error means

The build fails with "Duplicate class <name> found in modules ... and ...", naming two artifacts that both contain the class. It is deterministic and tied to your dependency graph.

Gradle output
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules
kotlin-stdlib-1.8.0 and kotlin-stdlib-jdk8-1.6.0
Go to the documentation to learn how to <a>resolve dependency conflicts</a>.

Diagnose it: SDK, signing, or simulator?

Mobile CI failures cluster into three: a missing or mismatched SDK component, a code-signing identity that does not exist on the runner, or a simulator or emulator that never became ready.

Terminal
# Android
sdkmanager --list_installed 2>/dev/null | head
echo "ANDROID_HOME=$ANDROID_HOME"
adb devices

# iOS
xcodebuild -version && xcrun simctl list devices available | head
security find-identity -v -p codesigning

Common causes

Two artifacts contain the same class

A library was split or renamed across versions (e.g. kotlin-stdlib-jdk8 merged into kotlin-stdlib), and both end up on the classpath.

Transitive version drift

Different dependencies pull different versions of a shared library, and the merged classpath contains duplicate classes.

How to fix it

Align versions with a BOM / platform

A platform constraint keeps related artifacts on one consistent version so duplicates disappear.

build.gradle.kts
dependencies {
  implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.0.20"))
  // related kotlin artifacts now share one version
}

Exclude the redundant artifact

When one artifact is obsolete, exclude it from the dependency that drags it in.

build.gradle.kts
implementation("com.example:lib:1.0") {
  exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
}

How to prevent it

  • Use a BOM/platform to keep related artifacts on one version.
  • Run ./gradlew :app:dependencies to spot duplicate sources.
  • Avoid mixing split/renamed artifact variants of the same library.

Frequently asked questions

What causes Android "Duplicate class" in CI?
There are 2 common causes: two artifacts contain the same class and transitive version drift. A library was split or renamed across versions (e.g.
How do I fix Android "Duplicate class" in CI?
There are 2 fixes depending on which cause you have: align versions with a bom / platform and exclude the redundant artifact. Work through them in order, since the first is the most common.
What does Android "Duplicate class" in CI actually mean?
The build fails with "Duplicate class <name> found in modules ...
How do I stop Android "Duplicate class" in CI happening again?
Use a BOM/platform to keep related artifacts on one version. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card