Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: Execution failed for task ':app:checkDebugDuplicateClasses'

Tags:

react-native

I am getting the next error appearing on running npx react-native run-android. It came out of nowhere - no changes have been committed.

Execution failed for task ':app:checkDebugDuplicateClasses'.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable

Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)

Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20)
     
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk7-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20)
     
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)
     
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules jetified-kotlin-stdlib-1.8.0 (org.jetbrains.kotlin:kotlin-stdlib:1.8.0) and jetified-kotlin-stdlib-jdk8-1.7.20 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20)

What I tried:

  1. Follow again the installation steps on official react native documentation page: https://reactnative.dev/docs/environment-setup

     brew install node
     brew install watchman
     brew tap homebrew/cask-versions
     brew install --cask zulu11
    
  2. Uninstall and install Android Studio

  3. Set kotlinVersion = "1.8.0" in android/build.gradle:

     buildToolsVersion = "32.0.0"
     minSdkVersion = 21
     compileSdkVersion = 33
     targetSdkVersion = 33
     // here
     kotlinVersion = "1.8.0"
    

It looks like if I get rid of "react-native-inappbrowser-reborn": "^3.7.0" library the error is gone and the app launches successfully. But what if I need react-native-inappbrowser-reborn in my project?

Thank you mates in advance!

like image 736
spatak Avatar asked May 11 '26 18:05

spatak


2 Answers

This is caused by the Kotlin plugin update. You can fix it easily by using configure below:

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.android.support:multidex:2.0.1'
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"

    // Add this line here
    implementation platform('org.jetbrains.kotlin:kotlin-bom:1.8.0')

    //...omit some code
}

You can refer this one: Kotlin Document

like image 67
user21098583 Avatar answered May 14 '26 08:05

user21098583


Add this to android/app/build.gradle

configurations.all {
resolutionStrategy {
    eachDependency {
        if ((requested.group == "org.jetbrains.kotlin") && (requested.name.startsWith("kotlin-stdlib"))) {
            useVersion("1.6.10")
        }
    }
}

}

like image 32
Attallah Qweider Avatar answered May 14 '26 07:05

Attallah Qweider