库'jna-4.2.2.jar'包含不能在Android设备上运行的本机库

时间:2016-06-20 04:43:02

标签: java android jna

我从互联网上下载了jna-4.2.2.jar,现在想将这个jar导入我的项目中。但是,当我尝试将此jar导入我的项目时,我收到以下错误。

[2016-06-20 09:35:01 - FaceVerificationApplication] The library 'jna-4.2.2.jar' contains native libraries that will not run on the device.
[2016-06-20 09:35:01 - FaceVerificationApplication] The following libraries were found:
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/darwin/libjnidispatch.jnilib
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-x86/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-x86-64/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-arm/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-aarch64/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-ppc64/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-ppc64le/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/linux-sparcv9/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/sunos-x86/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/sunos-x86-64/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/sunos-sparc/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/sunos-sparcv9/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/freebsd-x86/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/freebsd-x86-64/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/openbsd-x86/libjnidispatch.so
[2016-06-20 09:35:01 - FaceVerificationApplication]  - com/sun/jna/openbsd-x86-64/libjnidispatch.so

如何解决此错误?任何建议都有很大帮助。

3 个答案:

答案 0 :(得分:3)

我已经解决了我的问题。添加jna-4.2.2.jar后,在Eclipse中我必须转到Window>偏好> Android>构建>取消选中"当外部jar包含本机库时强制错误"。然后这个问题就解决了。

答案 1 :(得分:0)

似乎您的JAR包含非为Android构建的本机库(而是Linux,BSD,SunOS)。您应该查找包含使用Android NDK构建的ELF(* .so文件)的JAR。

我不确定,但可能here你可以找到合适的原生二进制文件。

答案 2 :(得分:0)

为方便起见,基础jna.jar包含一系列桌面平台的二进制文件。有时,特定的部署要求需要不同的配置,此时您只需要包含适合您情况的代码和/或二进制文件。

Android要求您以特定方式专门加载本机库,作为应用程序构建和部署的一部分。

您需要显式添加只是 Android二进制文件,并省略构建中的其他内容。