Duplicate class 🤖 Android

Duplicate class X found in modules A and B

Two dependencies ship the same class — typically old Android Support libraries mixed with AndroidX, or Kotlin stdlib-jdk7/jdk8 version mixes.

Seen on: Android

Meaning

The build merges all classes into one app; the same fully-qualified class in two artifacts is a conflict. The message names both modules, which tells you exactly which dependency to exclude or upgrade.

Common causes

  • Mixing com.android.support with AndroidX
  • Different Kotlin stdlib artifacts (kotlin-stdlib-jdk8 vs kotlin-stdlib) on mismatched versions
  • Two libraries bundling the same third-party code (Guava listenablefuture, protobuf-lite vs protobuf-java)

⚡ Quick fix

  1. Enable Jetifier / migrate to AndroidX
  2. Align Kotlin versions with the Kotlin BOM
  3. Exclude the duplicate module from one dependency
  4. Run ./gradlew app:dependencies to find who brings it in

Detailed fix by platform

Android

  1. Align Kotlin and exclude a duplicate:
    kotlin
    dependencies {
        implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.9.24"))
        implementation("com.example:legacy-lib:2.0") {
            exclude(group = "com.google.guava", module = "listenablefuture")
        }
    }

How to diagnose

  1. Modules — Which two artifacts are named?
  2. Tree — gradlew dependencies — who pulls each in?
  3. Versions — Can one upgrade remove the conflict?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.