使用64位的android 32位JNI库 [英] Use 32-bit jni libraries on 64-bit android

查看:1610
本文介绍了使用64位的android 32位JNI库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试使用本机库上的Nexus 9上运行的应用程序。

I've tried running an application using a native library on the Nexus 9.

有一个错误信息的应用程序退出:

The application exits with an error message:

java.lang.UnsatisfiedLinkError: dlopen failed: "lib_xyz.so" is 32-bit instead of 64-bit

是否有任何已知的解决这一问题(除,当然,重新编译库和决策的APK更大)?

Is there any known workaround for this problem (except, of course, recompiling the library and making the apk bigger)?

推荐答案

找到一个解释:64位的Andr​​oid可以使用32位本机库作为备用,只有当System.loadlLibrary()找不到什么更好的默认的搜索路径。 你得到的UnsatisfiedLinkError如果强制系统加载使用System.load()与全库路径的32位库。 因此,第一个解决方法是使用的System.loadLibrary()而不是System.load()。

Found an explanation: 64-bit Android can use 32-bit native libraries as a fallback, only if System.loadlLibrary() can't find anything better in the default search path. You get an UnsatisfiedLinkError if you force the system to load the 32-bit library using System.load() with the full library path. So the first workaround is using System.loadLibrary() instead of System.load().

这是必须要考虑的另外一个事情是,库不能混用:回退行为仅适用于第一个库应用程序的负载。如果第一个是64位的,没有32位的库可以通过相同的应用程序,反之亦然加载。

An additional thing that has to be taken into account is that libraries cannot be mixed: the fallback behaviour only applies for the first library your application loads. If the first one is 64-bit, no 32-bit libraries can be loaded by the same application, and vice versa.

这篇关于使用64位的android 32位JNI库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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