Skip to main content

Frequently asked questions


Duplicate classes

When compiling your project, you encounter an error from the kotlin.stdlib library explaining that you have a duplicate class ?

Caused by: java.lang.RuntimeException: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.20-dev-78 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20-dev-78) and kotlin-stdlib-jdk8-1.5.30 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30)

Add this configuration block to your app module build.gradle:

dependencies {
...
modules {
module("org.jetbrains.kotlin:kotlin-stdlib-jdk7") {
replacedBy("org.jetbrains.kotlin:kotlin-stdlib", "kotlin-stdlib-jdk7 is now part of kotlin-stdlib")
}
module("org.jetbrains.kotlin:kotlin-stdlib-jdk8") {
replacedBy("org.jetbrains.kotlin:kotlin-stdlib", "kotlin-stdlib-jdk8 is now part of kotlin-stdlib")
}
}
...
}

Decompilation error

If you are using a version of gradle prior to version 8, you may encounter the following error when integrating CMP (since version 4.X.X):

Error: com.android.tools.r8.internal.nc: Sealed classes are not supported as program classes

This is a "normal" error, as Gradle 7 is unable to decompile certain classes (Gradle 8 requires you to migrate to JAVA 17).

The only solution is to add the R8 plugin to your project.

The reference for this patch comes from a Google Issue and the solution is as follows:

pluginManagement {
buildscript {
repositories {
mavenCentral()
maven {
url = uri("https://storage.googleapis.com/r8-releases/raw")
}
}
dependencies {
classpath("com.android.tools:r8:8.2.20-dev")

}
}
}