Android JNA UnsatisfiedLinkError:未找到本机库(com/sun/jna/xxx/libjnidispatch.so) [英] Android JNA UnsatisfiedLinkError: Native library (com/sun/jna/xxx/libjnidispatch.so) not found

查看:142
本文介绍了Android JNA UnsatisfiedLinkError:未找到本机库(com/sun/jna/xxx/libjnidispatch.so)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我正在尝试使用JNA和libvirt java绑定建立一个android studio项目.

Hey I am trying to set up a android studio project with JNA and libvirt java bindings.

这是到目前为止的项目结构.

This is what the project structure looks like so far.

,但是该解决方案对我不起作用

however the solution did not work for me

到目前为止,尚未在模拟器上对此进行测试,并且尚未导入Arm二进制文件.

This is being tested not he emulator so far and the arm binaries have not been imported yet.

当尝试在libvirt java绑定中使用Connect方法时,出现此错误.

When trying to use Connect method in the libvirt java bindings I get this error.

此处

11-18 23:54:37.584 4182-4182/com.local.test E/AndroidRuntime: FATAL EXCEPTION: main
                                                           Process: com.local.test, PID: 4182
                                                           java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/android-x86/libjnidispatch.so) not found in resource path (.)
                                                               at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1039)
                                                               at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:999)
                                                               at com.sun.jna.Native.<clinit>(Native.java:191)
                                                               at com.sun.jna.Native.loadLibrary(Native.java:625)
                                                               at org.libvirt.jna.Libvirt.<clinit>(Unknown Source)
                                                               at org.libvirt.Library.<clinit>(Unknown Source)
                                                               at org.libvirt.Connect.<init>(Unknown Source)
                                                               at com.local.haris.MainActivity.onCreate(MainActivity.java:34)
                                                               at android.app.Activity.performCreate(Activity.java:6662)
                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                               at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                               at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                               at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                               at android.os.Handler.dispatchMessage(Handler.java:102)
                                                               at android.os.Looper.loop(Looper.java:154)
                                                               at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

注意: Android Studio 3.0 没有安装c ++ SDK(因为我不编译二进制文件,所以认为我不需要这样做) 如果不确定libvirt java jar是否可在android上运行.我试图找到有关此的信息,但没有成功.如果有人可以对此发表评论,将不胜感激.

Notes: Android studio 3.0 Do not have the c++ SDK installed (didn't think I needed to since I am not compiling binaries) If am unsure if the libvirt java jar works on android. I tried to find information about this but failed to do. If someone could comment on this it would be appreciated.

推荐答案

包括项目支持的所有Android ABI的libjnidispatch.so共享库.

Include the libjnidispatch.so shared library for all the Android ABIs that your project supports.

  • 导航到 JNA库.
  • 在4.5.0版以下,下载zip存档
  • 解压缩软件包,导航到jna-4.5.0/dist/目录.可以从相应的jar文件中提取用于不同ABI的libjnidispatch.so.映射如下表所示.

  • Navigate to JNA libraries.
  • Under Version 4.5.0, download the zip archive
  • Unzip the package, navigate to jna-4.5.0/dist/ directory. libjnidispatch.so for different ABIs can be extracted from respective jar file. The mapping is as below illustrated in below table.

| JNA ABI             | Android ABI   |
| ------------------- | ------------- |
| android-aarch64.jar | arm64-v8a     |
| android-armv7.jar   | armeabi-v7a   |
| android-x86-64.jar  | x86_64        |
| android-x86.jar     | x86           |

  • libjnidispatch.so放入映射的Android ABI文件夹中,例如arm64-v8aarmeabi-v7ax86x86_64.
  • Put the libjnidispatch.so into the mapped Android ABI folder, for example, arm64-v8a, armeabi-v7a, x86 and x86_64.
  • 这篇关于Android JNA UnsatisfiedLinkError:未找到本机库(com/sun/jna/xxx/libjnidispatch.so)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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