18

I created a new react-native project and added my android native module as a dependency.using official doc https://reactnative.dev/docs/native-modules-setup

When I run this I get the error with following stack trace:

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so result: 0
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:825)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:673)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:611)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:559)
        at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary(NativeLoaderToSoLoaderDelegate.java:25)
        at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:44)
        at com.facebook.jni.HybridData.<clinit>(HybridData.java:34)
        at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25) 

Following is my package.json

{
  "name": "albums",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "axios": "^0.19.2",
    "react": "16.11.0",
    "react-native": "0.62.0-rc.5",
    "react-native-my-fancy-library": "../react-native-my-fancy-library/"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0",
    "@babel/runtime": "^7.9.2",
    "@react-native-community/eslint-config": "^1.0.0",
    "babel-jest": "^25.3.0",
    "eslint": "^6.8.0",
    "jest": "^25.3.0",
    "metro-react-native-babel-preset": "^0.59.0",
    "react-test-renderer": "16.11.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

I have already tried:

https://stackoverflow.com/a/61695629/9715339

https://stackoverflow.com/a/57155606/9715339

https://github.com/facebook/react-native/issues/25415

But none of these solved my issue.

I am a beginner in react-native. So I don't know what other details files I need to post here. Do let me know if you need any other files.

Mayur Gajra
  • 8,285
  • 6
  • 25
  • 41

3 Answers3

47

For me the following two solved it (I think it was the latter that did it):

  1. Reset cache: react-native start --reset-cache
  2. Clean Android: cd android -> ./gradlew clean
MikeL
  • 2,756
  • 2
  • 23
  • 41
3

for me this is resolved after following below steps 3 steps

  1. Up minSdk to 23
  2. In gradle.properties add line: android.bundle.enableUncompressedNativeLibs=false;
  3. In your manifest file add line: android:extractNativeLibs=true;
Usama Nasir
  • 134
  • 5
  • It may be enough to set only `jniLibs { useLegacyPackaging true }` in the build.gradle file to package compressed native libraries - see https://developer.android.com/studio/releases/gradle-plugin?buildsystem=ndk-build#compress-native-libs-dsl – Klemens Zleptnig Oct 28 '22 at 11:06
2

I had the same problem that I solved by updating build.gradle 3.5.2 to 3.5.3 by Android Strudio.

enter image description here

The image shows the update of the classpath in the dependencies in the build.gradle file in the android folder

Moumit
  • 8,314
  • 9
  • 55
  • 59