How do i call C/C++ code from Android using JNA?

前端 未结 2 1137
醉酒成梦
醉酒成梦 2020-12-19 10:23

I\'m trying to integrate this specific library to my Android project, and the library is written in C/C++. I\'ve miraculously gotten ndk-build to give me the ne

相关标签:
2条回答
  • 2020-12-19 10:55

    Do go to project properties and build paths and remove JNA 4.0 and related classes. This will work!

    0 讨论(0)
  • 2020-12-19 11:18

    JNA provides a stub native library, libjnidispatch.so for a variety of platforms. You can build this library yourself, or extract one of the pre-built binaries from the project's lib/native/<platform>.jar packages.

    You include libjnidispatch.so in your Android project the way you would any other JNI library. This is required; you cannot rely on JNA to dynamically unpack and use its native library automatically like on other platforms. The JNA project includes details for doing so (as well as instructions for building libjnidispatch.so yourself).

    You then use jna.jar as you would any other Java jar file, and write your own (Java) mappings to match the native library you're trying to access. There's also a jna-min.jar which omits all the native platform libraries that are normally bundled in jna.jar.

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