React Native :执行任务“:app:mergeAlphaDebugNativeLibs”失败

72qzrwbm  于 2022-11-17  发布在  React
关注(0)|答案(1)|浏览(191)

我收到以下错误,我在Apple M1芯片上使用React Native,而React Native版本为0.64.1

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeAlphaDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > More than one file was found with OS independent path 'lib/armeabi-v7a/libfbjni.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

请帮助我解决此问题。
已尝试将以下代码添加到以下文件app/build.gradle,应用已成功构建,但崩溃。

android {
   // yout existing code
   packagingOptions {
        pickFirst '**/libc++_shared.so'
        pickFirst '**/libfbjni.so'
    }
}
c3frrgcw

c3frrgcw1#

这对我有用
添加到独占内容“android/build. gradle”:

allprojects {
    repositories {
        exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }
  //....
  }
}

记住跑步:

cd android && ./gradlew clean

相关问题