Android build

Duplicate class found in modules

Two libraries ship the same classes

Duplicate class found in modules. Two dependencies include the same Java or Kotlin classes — usually different Kotlin standard library versions pulled in by plugins.

Updated

What this error means

Two dependencies include the same Java or Kotlin classes — usually different Kotlin standard library versions pulled in by plugins.

Why it happens

Two dependencies on the release classpath ship the same classes. Plugin versions that pull different Kotlin standard-library artifacts are the common case.

The message tools print

Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.22 (org.jetbrains.kotlin:kotlin-stdlib:1.8.22) and kotlin-stdlib-jdk8-1.7.10 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10)

How to fix it

  1. Update the plugins involved so they agree on Kotlin.
  2. Or align Kotlin by adding the Kotlin BOM (org.jetbrains.kotlin:kotlin-bom, with your Kotlin version) as a platform dependency in android/app/build.gradle.
  3. Sync and build again.

Check a log that shows this

Paste the failing step into the build error explainer. It matches this message, and any others in the same log, in your browser. Nothing is uploaded.

Other Android build errors

Let the Android build run in CI

CapWrapp builds the release on GitHub Actions with the JDK and Android SDK the project needs, and signs it with the upload keystore it stores for you.

  • Free to start
  • No credit card
  • Sign in with Google or GitHub