简体   繁体   English

找不到android项目中的本机库(UnsatisfiedLinkError)

[英]Native library in android project not found (UnsatisfiedLinkError)

I have an android project and I added an external .jar file which contains several .class files and in addition some .so files.我有一个 android 项目,我添加了一个外部 .jar 文件,其中包含几个.class文件和一些.so文件。

When I try to use some methods which are provided by the .class files I get a UnsatisfiedLinkError-Exception which says that the implementation for those methods couldn't be found.当我尝试使用.class文件提供的一些方法时,我得到一个 UnsatisfiedLinkError-Exception,它表示找不到这些方法的实现。

Obviously the problem is that the .so libraries which contain the implementation were not correctly loaded/cannot be found.显然问题是包含实现的.so库没有正确加载/无法找到。

What do I have to do that the native libraries in the external .jar file can be found from the runtime?我该怎么做才能从运行时找到外部.jar文件中的本机库?


More details:更多细节:

I'm using AndroidStudio and the app is tested on the emulator with the device "Nexus 5 API 23 x86".我正在使用 AndroidStudio,并且该应用程序已在带有设备“Nexus 5 API 23 x86”的模拟器上进行了测试。 The .so files support x86 too. .so文件也支持 x86。

I copied the .jar file into the /app/libs folder.我将.jar文件复制到/app/libs文件夹中。 Then I right-clicked the file in the IDE and selected "Add as library".然后我在 IDE 中右键单击该文件并选择“添加为库”。

在此处输入图片说明

As you see that crash is saying that it could not load native library.如您所见,崩溃是说它无法加载本机库。 But why?但为什么?

在此处输入图片说明

First of all I checked my structure, If native library .so files located correctly.首先,我检查了我的结构,如果本机库 .so 文件位置正确。

Seems everything was okay except this crazy error.除了这个疯狂的错误,似乎一切都好。

Then after some research, I find out that some of android devices has 64-bit processors.然后经过一番研究,我发现一些 android 设备具有 64 位处理器。

This devices generates and check arm64 folder to load native library.该设备生成并检查 arm64 文件夹以加载本机库。 That was the problem.那就是问题所在。 Because my project does not have arm64 folder.因为我的项目没有 arm64 文件夹。

Here is the solution;这是解决方案;

defaultConfig{
          ndk {
              abiFilters "armeabi-v7a", "x86", "armeabi", "mips"
             }
         }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UnsatisfiedLinkError:找不到本地库“ wcepeer”(Mysaifu) - UnsatisfiedLinkError : Native library 'wcepeer' not found (Mysaifu) Android java.lang.UnsatisfiedLinkError与本机库 - Android java.lang.UnsatisfiedLinkError with native library 找不到UnsatisfiedLinkError本机方法-Android-Telegram - UnsatisfiedLinkError native method not found - Android-Telegram 找不到Android NDK UnsatisfiedLinkError本机方法 - Android NDK UnsatisfiedLinkError Native method not found 找不到本机UnsatisfiedLinkError异常Android JNI的实现 - No Implementation found for native UnsatisfiedLinkError Exception Android JNI 在Android应用程序上加载现有共享库(.so)时出错(找不到unsatisfiedlinkerror本机方法) - Error loading existing shared library (.so) on Android app (unsatisfiedlinkerror native method not found) UnsatisfiedLinkError - 无法加载库 - 在资源路径中找不到本机库 - UnsatisfiedLinkError - Unable to load library - Native library not found in resource path UnsatisfiedLinkError(未找到本机方法) - UnsatisfiedLinkError (Native method not found) UnsatisfiedLinkError:找不到本机方法 - UnsatisfiedLinkError: Native method not found UnsatisfiedLinkError:在资源路径 (.) 中找不到本机库 (com/sun/jna/android-x86-64/libjnidispatch.so) - UnsatisfiedLinkError: Native library (com/sun/jna/android-x86-64/libjnidispatch.so) not found in resource path (.)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM