Setting up JNA in Android Studio

后端 未结 3 860
慢半拍i
慢半拍i 2020-12-11 17:09

I try to import jna.jar into my project since JNA is a very useful tool to call Native library which is base on JNI.

OS: Windows 10

IDE: And

相关标签:
3条回答
  • 2020-12-11 17:20

    For Android, reference the JNA library adding @aar at the end of the string instead of downloading the JNA jar:

    https://github.com/java-native-access/jna/blob/master/www/FrequentlyAskedQuestions.md#jna-on-android

    0 讨论(0)
  • 2020-12-11 17:24

    Put the .so file in the following directory (when using android studio): yourproject\app\src\main\jniLibs\armeabi-v7a\libjnidispatch.so

    Update: Since some of you asked where to find the *.so file:

    On the official JNA site you will find all the supported architectures (30+) for download:

    https://github.com/java-native-access/jna/tree/master/lib/native

    Download the jar of the architecture you'd like and open it with some zip tool. In there you'll find the libjnidispatch.so file (of course only for unix architectures. For windows its a dll)

    0 讨论(0)
  • 2020-12-11 17:37

    I found this comment in a file in the library github repo - "If you're using Google's Eclipse plugin then you must manually remove libjnidispatch.so from jna.jar/lib/armeabi and add it into your project's libs/armeabi directory."

    Since this file was created in 2012 and Android Studio was still in very early phase and not super popular by that time, I assume it might be a valid note for Eclipse and also for Android Studio. I suggest you try it.

    0 讨论(0)
提交回复
热议问题