Android java.lang.UnsatisfiedLinkError: 找不到要加载的 DSO [英] Android java.lang.UnsatisfiedLinkError: couldn't find DSO to load

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

问题描述

我刚刚建立了一个全新的 react-native 项目 (0.62).运行新的调试版本工作正常.

I just set up a brand new react-native project (0.62). Running a fresh debug build works just fine.

我按照文档设置了签名:https://reactnative.dev/docs/signed-apk-android,并确保我使用以下 ABI:"armeabi-v7a"、"x86"、"arm64-v8a"、"x86_64".

I set up signing following the documentation: https://reactnative.dev/docs/signed-apk-android, and ensured that I'm using the following ABIs: "armeabi-v7a", "x86", "arm64-v8a", "x86_64".

为了测试发布版本,我运行以下命令:npx react-native run-android --variant release

To test out a release build, I run the following: npx react-native run-android --variant release

运行上述命令后,应用程序尝试启动并立即崩溃并显示以下堆栈跟踪:

After running the above command, the app attempts to start and crashes immediately with the following stack trace:

    --------- beginning of crash
2020-05-01 09:34:26.707 19961-19976/? E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: <BUNDLE_ID>, PID: 19961
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:789)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)

果然,当我解包 APK 时,/lib/x86_64 中没有 libhermes.so(我目前正在像素 2 API 28 上进行测试).

Sure enough, when I unpackage the APK there is no libhermes.so in /lib/x86_64 (I am testing at the moment on pixel 2 API 28).

我不确定为什么开始时没有启用 Hermes,但为了确保我在 build.grade 中设置了以下内容:

I'm not sure why hermes wasn't enabled to start out with, but just to be sure I set the following in my build.grade:

project.ext.react = [
    enableHermes: true,  // clean and rebuild if changing
]

现在在清理和构建之后,我确实看到了 libhermes.so.不幸的是,我仍然看到同样的问题.但是我可以看到该文件存在.

Now after cleaning and building I do see libhermes.so. Unfortunately, I am still seeing the same exact issue. But I can see that the file exists.

在这一点上,我很困惑.我关注了许多报告相同问题的线程(例如,this).听起来 soloader 的一个潜在问题已得到修复,并且正在与最新版本的 react native 一起使用.虽然我使用的是最新版本的 RN,但我仍然看到这个问题.

At this point, I'm pretty stuck. I've followed a number of threads reporting the same issue (for example, this). It sounds like an underlying issue with soloader has been fixed and is being used with the latest version of react native. Although I'm using the latest version of RN, I'm still seeing this issue.

不太熟悉 Android 开发,我可以采取哪些步骤来进一步调查此问题?

Not being terribly familiar with Android development, what steps might I take to investigate this issue further?

推荐答案

您可以通过将 configurations.all 添加到您的 build.gradle

you can use the old version of soloader by adding configurations.all into your build.gradle

configurations.all {
    resolutionStrategy {
        force "com.facebook.soloader:soloader:0.8.2"
    }
}

喜欢这个

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

configurations.all {
    resolutionStrategy {
        force "com.facebook.soloader:soloader:0.8.2"
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

如果以上步骤不起作用,请执行以下步骤

app/build.gradle.

android {
  ...
  // add the following packagingOptions 
  packagingOptions {
    pickFirst 'lib/x86_64/libjsc.so'
    pickFirst 'lib/arm64-v8a/libjsc.so'
  }
}

我们还在 app/build.gradle 的 defaultConfig 中添加了以下内容

We also added the following to the defaultConfig in the app/build.gradle

ndk {
  abiFilters 'armeabi-v7a', 'x86'
}

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

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