Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react native 2 files found with path 'lib/arm64-v8a/libfbjni.so' from inputs

I am getting this error since yesterday while running react native app and absolutely no changes were made which is crazy. I have wasted so many hours so decided to ask here. Already tried gradle clean and also deleting .gradle and build folders. Please check the error below -

Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
> 2 files found with path 'lib/arm64-v8a/libfbjni.so' from inputs:
  - C:\Users\DELL\.gradle\caches\transforms-3\fec30cdec6405e4005c100e8efa899d0\transformed\jetified-react-native-0.71.0-rc.0-debug\jni\arm64-v8a\libfbjni.so
  - C:\Users\DELL\.gradle\caches\transforms-3\09bb94ee0a520d6ded1278936c1d07c7\transformed\jetified-fbjni-0.3.0\jni\arm64-v8a\libfbjni.so
 If you are using jniLibs and CMake IMPORTED targets, see
 https://developer.android.com/r/tools/jniLibs-vs-imported-targets

In Mac it gives the following error -

* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> 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
like image 728
Steve Avatar asked Sep 03 '25 02:09

Steve


1 Answers

To fix this issue, you need to add the following in your android/build.gradle file.

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

What this fix will do is apply an exclusiveContent resolution rule that will force the resolution of React Native Android library, to use the one inside node_modules.

Once you update your app to React Native v0.71.0, this fix won't be needed anymore. Reason - The reason is very briefly explained here - Fix and updates on Android build failures

UPDATE - This also fixes issue with kotlin due to the same reason

Incompatible classes were found in dependencies.
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.4.0.

UPDATE - React Native team has pushed hotfix releases for all the main versions of react-native as below:

🛳 0.70.5: https://github.com/facebook/react-native/releases/tag/v0.70.5

🛳️ 0.69.7: https://github.com/facebook/react-native/releases/tag/v0.69.7

🛳 0.68.5: https://github.com/facebook/react-native/releases/tag/v0.68.5

🛳️ 0.67.5: https://github.com/facebook/react-native/releases/tag/v0.67.5

🛳️ 0.66.5: https://github.com/facebook/react-native/releases/tag/v0.66.5

🛳️ 0.65.3: https://github.com/facebook/react-native/releases/tag/v0.65.3

🛳️ 0.64.4: https://github.com/facebook/react-native/releases/tag/v0.64.4

🛳️ 0.63.5: https://github.com/facebook/react-native/releases/tag/v0.63.5

By updating to these patch versions in your package.json, your Android build should start working again.

like image 137
Steve Avatar answered Sep 07 '25 13:09

Steve