---
title: "How do you fix \"Duplicate class found in modules\" in Android Gradle builds?"
description: "Two dependencies bring in the same class. Find the conflict with a dependency report, then exclude one copy or align the versions."
url: "https://bugsee.com/answers/android/fix-duplicate-class-found/"
---

# How do you fix "Duplicate class found in modules" in Android Gradle builds?

Two libraries on your classpath contain the same class. Find which ones with the Gradle dependency report, then exclude one or align their versions.

```bash
./gradlew :app:dependencies --configuration releaseRuntimeClasspath
```

The error message names the class and the two modules that contain it. Search the report for those modules to see which of your dependencies pulls each one in. Then pick one fix:

```kotlin
// build.gradle.kts
dependencies {
    implementation("com.example:library-a:2.1.0") {
        exclude(group = "com.example", module = "legacy-core")
    }
}

// Or force one version for every dependency
configurations.all {
    resolutionStrategy.force("com.example:core:2.1.0")
}
```

A common real-world case is the same library appearing under an old and a new coordinate, such as the Android Support libraries alongside AndroidX. Migrating fully to AndroidX removes that conflict.

## Related questions

- [How do you deobfuscate an Android stack trace?](https://bugsee.com/answers/android/deobfuscate-a-stack-trace/)
