2

I am getting the following error and I am using React Native on Apple M1 chip and the react native version is 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

Please help me resolve this issues.

Tried add below code to the following file app/build.gradle, app was build successfully but it crashed.

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

  • 1
    Does this answer your question? [React Native Android build failure with different errors without any changes in code for past days due to publish of React Native version 0.71.0-rc.0](https://stackoverflow.com/questions/74334162/react-native-android-build-failure-with-different-errors-without-any-changes-in) – Thanhal P A Nov 10 '22 at 12:18
  • we are using react native 0.64.1 – Shariq Ahmed - Nov 10 '22 at 12:26
  • This issue is happening for lower version. Just try if that solution works? – Thanhal P A Nov 10 '22 at 12:32
  • Thanks alot buddy. Method 1 worked but app was crashing frequently, so tried method 2 and its working fine. But still its crashing... any alternate solution for it? – Shariq Ahmed - Nov 10 '22 at 12:42
  • https://stackoverflow.com/questions/74370367/my-react-native-was-working-fine-upto-4-november-but-now-throwing-an-exception-w – Thanhal P A Nov 11 '22 at 13:38

1 Answers1

0

this work for me.

add to 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"
                }
            }
        }
  //....
  }
}

Remember run:

cd android && ./gradlew clean
Mustafa Poya
  • 2,615
  • 5
  • 22
  • 36