Getting “java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so” error

耗尽温柔 提交于 2019-12-23 10:52:56

问题


I'm in the process of migrating a React Native project from react-native version 0.58.5 to 0.60.4.

For the Android part I've done all the changes mentioned here

I let Hermes disabled in my app build.gradle file:

project.ext.react = [
    entryFile: "index.js",
    enableHermes: false,  // clean and rebuild if changing
]
...
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
...
dependencies {
    ...

    if (enableHermes) {
      println 'Hermes is enabled'
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      println 'Hermes is disabled'
      implementation jscFlavor
    }
}
...

I can see the Hermes is disabled print at build time. And this is exactly what I want.

When launching the Android app with react-native run-android I get the following crash at startup :

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

After some research I could see this crash occurs for people wanting to enable Hermes and that has a wrong gradle configuration : [0.60.3] App crash on startup when enabling Hermes (enableHermes: true)

Why am I getting this crash while Hermes is disabled?

Note that when setting enableHermes to true no crash occurs.


回答1:


I solved this problem by a tiny change after doing this steps in this article

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

Then make sure to add this jsc-android block to your android/build.gradle:

`allprojects {
   repositories {
      maven {
         url("$rootDir/../node_modules/react-native/android")
      }

      maven {

          url "$rootDir/../node_modules/react-native/android"

     }


     google()
     jcenter()
  }
}`



回答2:


I solved this problem by this steps

  1. install hermesvm : npm i hermesvm
  2. install jsc-android : npm i jsc-android

3.add this lines to app/build.gradle

project.ext.react = [
   entryFile: "index.js" ,
   enableHermes: false
]

def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);


dependencies {
   if (enableHermes) {
       def hermesPath = "../../node_modules/hermesvm/android/";
       debugImplementation files(hermesPath + "hermes-debug.aar")
       releaseImplementation files(hermesPath + "hermes-release.aar")
    }
   else { implementation jscFlavor }
  1. add this jsc-android block to your android/build.gradle:

    allprojects { repositories { maven { url("$rootDir/../node_modules/react-native/android") } maven { url "$rootDir/../node_modules/react-native/android" } google() jcenter() } }




回答3:


Double-check please all the updates here - https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.60.5

I had the same error, because made a mistake in migration of the android/app/build.gradle file.



来源:https://stackoverflow.com/questions/57113794/getting-java-lang-unsatisfiedlinkerror-couldnt-find-dso-to-load-libhermes-so

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!