Skip to content
Latchkey

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.0

Common 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

  1. Identify the two modules in the error.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →