What this thread does
Do first: search the class named by Duplicate class in Navigate > Class with Include non-project items, then inspect the failing variant's runtime graph.
Short answer
As of November 2026, use the Gradle 9.9.1 dependency diagnostics with your project's compatible wrapper; this is not an instruction to upgrade AGP. Identify both class owners before changing dependencies. Align versions of the same library; exclude only a redundant module that the retained graph can do without.
Choose / don't choose
- Version alignment: choose for mixed Kotlin stdlib artifacts. Kotlin's 28 December 2022 notes explain the JDK-specific merge in 1.8.0. The historical replacement is
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0"); the retained alignment example isimplementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")). Choose your project's compatible Kotlin line today, not that historical number. - Edge exclusion: choose when another artifact supplies the intended implementation; don't remove a required runtime library. An exclusion on one incoming edge leaves other incoming edges intact (Gradle exclusions).
- Duplicate binaries: choose removal of either the local or remote copy, or an unbundled distribution when a retained AAR/JAR embeds the classes (Android).
Not for: Android Studio Unresolved reference when Gradle succeeds; see android-studio-unresolved-reference-everywhere-but-gradle-builds-fine.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
dependencies --configuration | debugRuntimeClasspath for ordinary debug packaging; use the actual failing flavor/build-type runtime configuration | Gradle 9.9.1 release notes | Android graph, report |
dependencyInsight --dependency | Exact group:name of each owning artifact, or a matching fragment | Gradle 9.9.1 | insight |
dependencyInsight --configuration | Dependency configuration that resolves the dependency; don't accept the Java plugin's compileClasspath fallback | Gradle 9.9.1 | insight |
--single-path | Omit while finding every incoming path; enabling it hides other routes | Gradle 9.9.1 | path reporting |
exclude(group = "com.example.imgtools", module = "native") | Replace both example coordinates with the redundant module, inside its introducing dependency declaration | Current Android docs | exact syntax |
kotlin.stdlib.jdk.variants.version.alignment | Remove a deliberate false opt-out only after reviewing why it exists; use alignment instead of deleting needed stdlib modules | KGP alignment for stdlib 1.8.0–1.9.10; stdlib metadata alignment from 1.9.20 | current alignment rules |
Order of operations
1. Identify the two artifacts from the failure and Android Studio class search. Distinguish two module versions from copied/embedded binaries. 2. Run ./gradlew :app:dependencies --configuration debugRuntimeClasspath, substituting the actual module and runtime configuration. Then run ./gradlew :app:dependencyInsight --dependency group:name --configuration debugRuntimeClasspath for both owners. These compose Gradle's documented task syntax with Android's runtime configuration; group:name is a placeholder (reports). 3. Select the intended implementation. Align required modules; otherwise apply an exclusion at every necessary incoming edge. Repeat the report to confirm why each remaining artifact is selected (exclusion scope). 4. Rebuild the original variant using its existing build command, then exercise the affected feature. Repeat for release if it has a different graph; a debug graph says nothing about release packaging.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
Duplicate class | Mixed stdlib/JDK artifacts or two binaries owning one class | Align the Kotlin line or remove the redundant binary; midnighthowlers' report names stdlib 1.8.0 beside jdk8 1.6.0 | report, Kotlin merge |
NoClassDefFoundError | An exclusion removed a class another dependency needs at runtime | Restore that module and resolve the conflict through compatible versions instead | Gradle runtime warning |
The retained AGP 8.9 March 2025 release notes include 8.9.2, Gradle 8.11.1 minimum and JDK 17. They are a historical compatibility reference, not a duplicate-class fix. Keep KGP/Gradle/AGP within the documented compatibility ranges.
Missing
- The linked source does not confirm: Graph exclusions cannot edit a binary's contents.
- No project graph, artifact coordinates or failing variant is specified; neither the correct exclusion nor a compatible numeric alignment version can be selected universally.
Checked
2026-11-12; Gradle 9.9.1 release and dependency references, current Android/Kotlin references, retained Kotlin/AGP release notes and midnighthowlers report read. No build commands executed.
Started from a post by @Google, packaged by the editor. Original post