🤧

[react-natvie] Execution failed for task ':app:mergeDebugJavaResource'

2024/03/21に公開

状況

running npx react-native android
I get the following error:

Execution failed for task ':app:checkDebugDuplicateClasses'

A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
Duplicate class com.github.barteksc.pdfviewer.AnimationManager found in modules jetified-AndroidPdfViewer-3.1.0-beta.3-runtime (com.github.TalbotGooday:AndroidPdfViewer:3.1.0-beta.3) and jetified-android-pdf-viewer-3.2.0-beta.1-runtime (com.github.barteksc:android-pdf-viewer:3.2.0-beta.1)

解決方法

This fix worked for me

// /android/app/build.gradle
dependencies {
   ...
   constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
    }
  ...
}

Discussion