dalvik.system.PathClassLoader找不到英特尔设备JNI英特尔、找不到、设备、system

2023-09-07 09:11:50 作者:缺烟缺酒缺女人ぃ

我有一个问题,即dalvik.system.PathClassLoader找不到英特尔的设备我的JNI文件。我认为它做一个AAR依赖我的结构,因为一旦我删除了依赖,是没有问题找到了JNI文件。我AAR依赖有x86和ARM库,而我的项目只有ARM库。

I'm having an issue where the dalvik.system.PathClassLoader can't find my jni file on Intel devices. I think it has to do with the structure of an aar dependency I have because once I removed that dependency, the jni file is found without issue. My aar dependency has x86 and arm libraries and my project only has arm libraries.

文件夹结构为:

我的项目

  在SRC       jniLibs       armeabi       libLibraryA.so    src jniLibs armeabi libLibraryA.so

我的AAR相关项目有:

My AAR dependency Project has:

  在SRC       jniLibs       armeabi       libLibraryB.so    src jniLibs armeabi libLibraryB.so    libLibraryB.so   

通过该结构,libLibraryA.so不会在x86设备发现。我不知道这是否是一个摇篮的包装问题,或者如果这是一个的Dalvik /运行时的问题。我在哪里去旁边的损失。我得到的错误是:

With that structure, libLibraryA.so will not be found on x86 devices. I'm not sure if this is a gradle packaging issue or if this is a dalvik/runtime issue. I'm at a loss of where to go next. The error I get is:

致命异常:主要 工艺:com.project,PID:10850 java.lang.UnsatisfiedLinkError中:dalvik.system.PathClassLoader [DexPathList [zip文件/base.apk"],nativeLibraryDirectories=[/lib/x86,/供应商/ lib中/系统/ lib目录]]]找不到 libLibraryA.so 在java.lang.Runtime.loadLibrary(Runtime.java:366) 在java.lang.System.loadLibrary(System.java:989)

FATAL EXCEPTION: main Process: com.project, PID: 10850 java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/base.apk"],nativeLibraryDirectories=[/lib/x86, /vendor/lib, /system/lib]]] couldn't find "libLibraryA.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at java.lang.System.loadLibrary(System.java:989)

我知道在我的项目中创建一个x86文件夹并复制libLibraryA.so到其中的问题都可以固定。有谁知道,如果摇篮可以/应处理这对我?它是安全的一只胳膊编译库到x86文件夹中使用英特尔的设备或将是搞乱了运行时的翻译?我已经看到了Nexus播放器问题如不能阅读我们的胳膊编译库。

I know the issue can be 'fixed' by creating an x86 folder in my project and copying libLibraryA.so into it. Does anyone know if gradle can/should be handling this for me? Is it safe to put an arm compiled library into the x86 folder for use on intel devices or would that mess up the runtime translation? I've seen issues on the Nexus Player where it can't read our arm compiled library.

推荐答案

您可以混合编为x86和ARM的库,只有当他们不依赖于对方(即如果他们不打电话给对方的情况下直接要通过Java)。

You can mix libs compiled for x86 and for arm only if they don't depend on each other (ie. if they don't call each other directly without going through Java).

所以,摇篮就不会混针对不同的架构库,它真的是你的责任,做到这一点,最简单的办法确实是复制你的 libLibraryA.so 到x86文件夹

So gradle will not mix libs targeting different architectures, it's really your responsibility to do that and the most simple way is indeed to copy your libLibraryA.so to an x86 folder.

但是这样做,这是一个的解决方法的,将工作只能在零售基于英特尔芯片的设备。我不建议:正确的事情仍然会得到一个版本的 libLibraryA.so 编译为x86和把它在x86文件夹内

But doing this is a workaround that will work only on retail Intel-based devices. I don't recommend that: the right thing to do would still be getting a version of libLibraryA.so compiled for x86 and putting it inside the x86 folder.

更新:不支持了采用Android 5.0的说,在我下面的评论,从加载应用程序的x86文件夹臂的lib

update: as said in my comment below, loading an arm lib from the app's x86 folder isn't supported anymore with Android 5.0.