Home > Net >  2 files found with path 'lib/arm64-v8a/libnode.so' - Problem with jniLibs for nodejs-mobil
2 files found with path 'lib/arm64-v8a/libnode.so' - Problem with jniLibs for nodejs-mobil

Time:12-14

I have been trying to get nodejs-mobile-react-native to work on Android but I'm getting the following error when I tried to build the project:

> Task :nodejs-mobile-react-native:mergeDebugNativeLibs FAILED

Execution failed for task ':nodejs-mobile-react-native:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction
   > 2 files found with path 'lib/arm64-v8a/libnode.so' from inputs:
      - /Users/<me>/projects/react-native/<my project>/node_modules/nodejs-mobile-react-native/android/build/intermediates/merged_jni_libs/debug/out/arm64-v8a/libnode.so
      - /Users/<me>/Projects/react-native/<my project>/node_modules/nodejs-mobile-react-native/android/build/intermediates/cxx/Debug/4a1j5e35/obj/arm64-v8a/libnode.so
     If you are using jniLibs and CMake IMPORTED targets, see
     https://developer.android.com/r/tools/jniLibs-vs-imported-targets

I have this setup for the project:

"react": "^17.0.2",
"react-native": "^0.66.3",
"nodejs-mobile-react-native": "^0.6.3",

Gradle version 7.0.2
Java version 11
NDK version 21.4.7075529
CMake version 3.18.1
Android SDK Platform 31 (12)

I tried these settings (and without) in my app/build.gradle but it didn't work

packagingOptions {
  pickFirst 'lib/armeabi-v7a/libnode.so'
  pickFirst 'lib/arm64-v8a/libnode.so'
  pickFirst 'lib/x86/libnode.so'
  pickFirst 'lib/x86_64/libnode.so'
}

CodePudding user response:

I found the solution.

The problem was that the packagingOptions had to be applied to the gradle file of the nodejs-mobile-react-native project here

/node_modules/nodejs-mobile-react-native/android/build.gradle

To do that automatically I had to create a bash script that adds these lines

packagingOptions {
  pickFirst 'lib/armeabi-v7a/libnode.so'
  pickFirst 'lib/arm64-v8a/libnode.so'
  pickFirst 'lib/x86_64/libnode.so'
  pickFirst 'lib/x86/libnode.so'
}

right above the lintOptions and invoke that bash script with the postinstall script of the package.json file.

  • Related