Android ReactNative java.lang.UnsatisfiedLinkError:could find DSO to load: libreactnativejni.so
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43368926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android ReactNative java.lang.UnsatisfiedLinkError:could find DSO to load: libreactnativejni.so
提问by Anu
I have been trying to add ReactNative to my existing android application. I followed the instructions from thislink. I could add it but the app gets crashed once I open the react native activity. I have started server using
我一直在尝试将 ReactNative 添加到我现有的 android 应用程序中。我按照此链接中的说明进行操作。我可以添加它,但是一旦我打开本机活动,应用程序就会崩溃。我已经开始使用服务器
adb reverse tcp:8081 tcp:8081
and started react-native using
并开始使用本机反应
react-native start
I get a dialogue that the js files are loading. But finally end up with a crash. Following is the error that is being printed in logcat:
我收到一个对话框,说 js 文件正在加载。但最终以崩溃告终。以下是在 logcat 中打印的错误:
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:213)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:178)
at com.facebook.react.bridge.JSCJavaScriptExecutor.<clinit>(JSCJavaScriptExecutor.java:19)
at com.facebook.react.ReactInstanceManager.onJSBundleLoadedFromServer(ReactInstanceManager.java:413)
at com.facebook.react.ReactInstanceManager.createReactContextInBackground(ReactInstanceManager.java:236)
I am completely lost as I am unable to figure out the cause for this issue.
我完全迷失了,因为我无法找出这个问题的原因。
Thanks in advance.
提前致谢。
采纳答案by Arnold Schrijver
This is caused by the following issue (open for 2 years) https://github.com/facebook/react-native/issues/2814
这是由以下问题引起的(开放 2 年)https://github.com/facebook/react-native/issues/2814
From the issue:
从问题:
React Native on Android doesn't provide a 64-bit version of the
libreactnativejni.so
native library, which can cause compatibility issues on 64-bit devices. I ran into this while attempting to integrate React Native with a large existing application I'm developing.
Android 上的 React Native 不提供 64 位版本的本
libreactnativejni.so
机库,这可能会导致在 64 位设备上出现兼容性问题。我在尝试将 React Native 与我正在开发的大型现有应用程序集成时遇到了这个问题。
Reaction from Facebook:
脸书的反应:
"Thanks for reporting! Yes we don't provide 64-bit version of the native code and the system should always fall back to 32-bit."
And:
"Most Android projects use a number of 3rd-party libraries, and any that include native 64-bit code will cause React Native to fail."
"感谢您的报告!是的,我们不提供 64 位版本的本机代码,系统应始终回退到 32 位。"
和:
"大多数 Android 项目使用了许多 3rd 方库,任何包含本机 64 位代码的项目都会导致 React Native 失败。"
The following SO answer Use 32-bit jni libraries on 64-bit androidexplains fallback to 32-bit libraries and the fact you cannot mix. So if 64-bit is found, all should be 64-bit
以下 SO 答案在 64 位 android 上使用 32 位 jni 库解释了回退到 32 位库以及您不能混合的事实。所以如果找到 64 位,所有的都应该是 64 位的
I suggest reading along the Github issue #2814. There are multiple fixes proposed, but it depends on your situation what works.
我建议阅读 Github 问题 #2814。提出了多种修复方法,但这取决于您的具体情况。
The issuer has also written a blog about it: Mixing 32- and 64-bit Dependencies in Android
发行人还写了一篇关于它的博客:在 Android 中混合 32 位和 64 位依赖项
Hope this helps!
希望这可以帮助!
回答by Aristo Michael
This has fixed my issue :
这解决了我的问题:
ndk {
abiFilters 'armeabi-v7a', 'x86'
}
This should be placed build.gradle
defaultConfig section.
这应该放在build.gradle
defaultConfig 部分。
回答by Vinícius Pacheco Vieira
回答by Najaf Ali
I solved this issue, update fresco library that is support for app bundle is 2.0.0 below this will not support,
我解决了这个问题,更新支持 app bundle 的 fresco 库是 2.0.0 以下这将不支持,
Update: For me the issue got solved after updating fresco to 2.0.0, because 1.11.0 apparently didn't have support for Android App Bundles. I don't know if you all had the same problem, though.
更新:对我来说,在将 fresco 更新到 2.0.0 后问题得到了解决,因为 1.11.0 显然不支持 Android App Bundles。不知道大家有没有遇到同样的问题。
just do this :
只需这样做:
implementation 'com.facebook.fresco:fresco:2.0.0'
回答by Muhammad Numan
you can use the old version of soloader by adding configurations.allinto your build.gradle
您可以通过将configuration.all添加到您的build.gradle 中来使用旧版本的soloader
configurations.all {
resolutionStrategy {
force "com.facebook.soloader:soloader:0.8.2"
}
}
like this
像这样
// 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
}
回答by Shubham Sharma
if you are fresco libray then make sure use latest version and set the properties as false :
如果您是 fresco libray,请确保使用最新版本并将属性设置为 false :
shrinkResources false
minifyEnabled false
Inside build.gradle
file.
里面的build.gradle
文件。