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

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

问题描述

我刚刚建立了一个全新的本机反应项目(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.

在这一点上,我还很困.我遵循了多个报告相同问题的线程(例如,).听起来,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?

推荐答案

您可以通过在 build.gradle 中添加 configurations.all 来使用旧版本的soloader./p>

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天全站免登陆