得到"java.lang.UnsatisfiedLinkError:找不到要加载的DSO:libhermes.so".错误 [英] Getting "java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so" error

查看:123
本文介绍了得到"java.lang.UnsatisfiedLinkError:找不到要加载的DSO:libhermes.so".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将React Native项目从react-native版本0.58.5迁移到0.60.4.

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

对于Android部分,我已经进行了提及的所有更改

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

我让爱马仕在我的应用程序 build.gradle 文件中禁用:

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
    }
}
...

我可以看到 Hermes已禁用在构建时打印.这正是我想要的.

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

当使用react-native run-android启动Android应用程序时,在启动时出现以下崩溃:

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)

经过一些研究,我发现有人希望启用Hermes并且崩溃配置错误,就会发生此崩溃: [0.60.3]启用Hermes时启动时应用崩溃(enableHermes:true)

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)

为什么在爱马仕(Hermes)被禁用的情况下会发生此崩溃?

Why am I getting this crash while Hermes is disabled?

请注意,将 enableHermes 设置为 true 时,不会发生崩溃.

Note that when setting enableHermes to true no crash occurs.

推荐答案

在执行了本文中的步骤之后,我通过一个很小的更改解决了这个问题

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

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

然后确保将此jsc-android块添加到android/build.gradle:

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

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }

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

        google()
        jcenter()
    }
}

这篇关于得到"java.lang.UnsatisfiedLinkError:找不到要加载的DSO:libhermes.so".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆