My react native project build fails somehow because of this error:
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:UsersAntonio.gradlecachestransforms-37cca348744e25f57fc2d9f871aa73c9atransformedjetified-react-native-0.71.0-rc.0-debugjniarm64-v8alibfbjni.so
- C:UsersAntonio.gradlecachestransforms-38b0f5c7017bf081f79b63ea5b053dc0transformedjetified-fbjni-0.3.0jniarm64-v8alibfbjni.so
If you are using jniLibs and CMake IMPORTED targets, see
https://developer.android.com/r/tools/jniLibs-vs-imported-targets
Anybody got a clue what could cause the build to fail? I haven’t edited any build file and/or removed/installed/upgraded new packages thanks
8
Answers
For me this worked (after reading Tony’s link), my version of react was 0.66.0
Changed this file androidappbuild.gradle
to
Here’s a workaround to fix this problem if you are not using latest version of react-native.
https://github.com/facebook/react-native/issues/35210
Go to android folder -> build.gradle file -> inside allprojects object and add following code. Add react native version from node_modules -> react-native -> package.json // "version": "0.68.2".
See fb/rn#35204
work for me, if your react native application version >= 0.63 you can update the patch version which should fix your problem.
link: https://github.com/facebook/react-native/issues/35210#:~:text=We%20have%20prepared%20releases%20for%20all%20the%20main%20versions%20of%20react%2Dnative%20with%20an%20hotfix%3A
if not just go to android/build.gradle and then in the allprojects object add the following code with the current version of react native in package.json
I had the same issue. There is a new patch for react-native now so update it in your package.json.
Mine is
and I changed it to
which worked for me
The answer lies here depending on the version of your react native. Patches are available for RN version 0.63 and up
https://github.com/facebook/react-native/issues/35210
Tips:
Short answer:
in your android/app/build.gradle
change
to —> (replace 0.67.2 with your current react native version)
Long answer:
This is happening because all the templates reference the React Native dependency by range, like
implementation 'com.facebook.react:react-native:+'
. Usually this dependency gets resolved from the local Maven repo in ./node_modules/react-native/android but since it has been published to Maven Central it’s now grabbing the very latest RC.You can resolve this problem by forcing the React Native dependency to the version you expect with something like this
implementation 'com.facebook.react:react-native:0.67.2!!'
in your app’s Gradle file. The!!
is shorthand for restricting Gradle from upgrading if your project or its transitive dependencies depend on a newer version.This is the Official recommended fix!
Found through this issue: https://github.com/facebook/react-native/issues/35210.
Copied from this PR here
For my RN 0.66.0 project I only had to add theses lines: