簡體   English   中英

React Native:任務 ':app:mergeAlphaDebugNativeLibs' 執行失敗

[英]React Native : Execution failed for task ':app:mergeAlphaDebugNativeLibs'

我收到以下錯誤,我在 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'
    }
}

這對我有用。

添加到 exclusiveContent '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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM