Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native :java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so

I have just updated my project to use react-native version 0.60.2 . But when I am trying to run an application on Android device it gets crashed after launch screen. I got the following error logs :

E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.tjspeed, PID: 3909
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
        at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20)
        at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create(HermesExecutorFactory.java:27)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
        at java.lang.Thread.run(Thread.java:760)

Few suggestions available here : https://github.com/facebook/react-native/issues/25601 but unfortunately none of them worked for me. Please suggest the workaround.

like image 716
V-Xtreme Avatar asked Jul 15 '19 08:07

V-Xtreme


4 Answers

I had the same issue after upgrading from 0.59.8 to 0.60.4

Make sure you have added all these lines in your app/build.gradle, especially the dependencies part as this makes sure you have JSC binary

project.ext.react = [

...
    // your index js if not default, other settings
  // Hermes JSC ?
 enableHermes: false,

...
]

def jscFlavor = 'org.webkit:android-jsc:+'

def enableHermes = project.ext.react.get("enableHermes", false);

dependencies {

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+"  // From node_modules

    if (enableHermes) {
      // For RN 0.60.x
      def hermesPath = "../../node_modules/hermesvm/android/"

      // --- OR ----          

      // for RN 0.61+
      def hermesPath = "../../node_modules/hermes-engine/android/";


      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }

EDIT

Also, make sure the Hermes Maven repo is in your root build.gradle

maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }
like image 128
Vinzzz Avatar answered Nov 02 '22 23:11

Vinzzz


I've just cleaned the build folder for android and after that, it worked fine. Hope that helps mate.

cd android
./gradlew clean 
like image 47
samernady Avatar answered Nov 02 '22 23:11

samernady


I added this block in allProject block in project_dir/build.gradle and the crash went away.

    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }

What I did is to create new project with react-native init and went through the android build files. Fortunately this one was the first difference I noticed and fixed my issue. I guess you could do the same if this doesn't work.

like image 24
skang Avatar answered Nov 02 '22 23:11

skang


In case you're facing this error while updating to React Native version 0.62.2:

Add the following to your android/app/build.gradle file:

dependencies {
   implementation 'com.facebook.soloader:soloader:0.9.0+'

as one of the first implementation entries.

Solution taken from here

like image 16
Andru Avatar answered Nov 02 '22 21:11

Andru