Skip to content

Android build errorAndroid: “Duplicate class ... found in modules”

The Android build (Gradle, Flutter or React Native) stops with Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.0 and kotlin-stdlib-jdk8-1.7.10, or a similar line for another library. The same class arrives through two dependencies, and the build will not pick one for you. The two module names in the message tell you where each copy comes from.

Short answer

Read the two module names in the error. If they are kotlin-stdlib and kotlin-stdlib-jdk7 or -jdk8, align the Kotlin versions: update the Kotlin Gradle plugin and any library pinning an old stdlib, or add the Kotlin BOM. If the same library appears twice (a local .jar plus the Maven artifact, or bundled inside another library), remove one. Otherwise run ./gradlew app:dependencies, find which dependency brings the second copy, and exclude that module from it.

Where the second copy comes from, and the fix

  1. 01

    Mixed Kotlin standard library versions

    “Note that mixing different versions of stdlib artifacts could lead to class duplication or to missing classes.” Kotlin, What’s new in Kotlin 1.8.0

    Since Kotlin 1.8, the contents of kotlin-stdlib-jdk7 and kotlin-stdlib-jdk8 live in kotlin-stdlib. A project or plugin that still pulls an older jdk8 artifact next to a new kotlin-stdlib gets the same classes twice. Update the Kotlin Gradle plugin (in Flutter, in android/settings.gradle, or ext.kotlin_version in android/build.gradle on older projects), update the libraries that pin old versions, and replace explicit jdk7 or jdk8 dependencies with kotlin-stdlib. The Kotlin BOM aligns the rest.

    // app/build.gradle.kts
    dependencies {
      implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.24"))
    }
  2. 02

    The same library is included twice

    “Your app has a local binary dependency and a remote binary dependency on the same library. To resolve this issue, remove one of the binary dependencies.” Android Developers, Fix dependency resolution errors

    A .jar or .aar copied into libs/ and the same library from Maven, or a library that already bundles another one you also declare, both put the classes on the classpath. Remove the direct dependency or the local file.

  3. 03

    Find which dependency brings the copy

    “Type the name of the class that appears in the build error. Inspect the results for the dependencies that include the class.” Android Developers, Fix dependency resolution errors

    Print the dependency tree and search it for the module names from the error. In Android Studio, Navigate > Class with Include non-project items checked shows every library that contains the class.

    # from the android folder in Flutter and React Native projects
    cd android && ./gradlew app:dependencies --configuration releaseRuntimeClasspath | grep -n "stdlib"
  4. 04

    Old support libraries next to AndroidX

    Duplicate class android.support.v4... next to androidx... means an old library still uses the Android Support Library. Set android.useAndroidX=true in gradle.properties, update the library to an AndroidX version, and enable android.enableJetifier=true only as a stopgap, because it slows every build.

    # android/gradle.properties
    android.useAndroidX=true
    android.enableJetifier=true  # temporary, until the old library is updated
  5. 05

    Exclude the module from the dependency that brings it

    When a library you need brings an extra copy you cannot remove by upgrading, exclude that module from it. A common case is Guava’s listenablefuture clashing with a full Guava.

    // Kotlin DSL (build.gradle.kts)
    dependencies {
      implementation("some-library") {
        exclude(group = "com.google.guava", module = "listenablefuture")
      }
    }
    
    // Groovy (build.gradle, Flutter and React Native)
    implementation('some-library') {
      exclude group: 'com.google.guava', module: 'listenablefuture'
    }

Checked against the vendor’s docs on : Android Developers: Fix dependency resolution errors (duplicate classes); Kotlin: What’s new in Kotlin 1.8.0 (jdk7 and jdk8 merged into kotlin-stdlib).

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Flutter Kotlin Gradle plugin version · Android “Manifest merger failed” · Gradle “Could not resolve all files”

Questions

More on this error

Why did it start after adding one package?

That package depends on a different version of a library you already have, often an older Kotlin stdlib. Update the package or the Kotlin plugin first; exclude a module only if updating does not remove the clash.

Should I use a resolution strategy to force a version?

Forcing one version can work, but it can also break the library that needed the other version at runtime. Prefer updating the libraries so they agree, and test the release build after any forced version.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.