My problem is when using jna to bridge from c/c++ .so I receive "could not invoke MyCaller.testFunc because libjnidispatch.so not found in resource path (.)"
It neither works if I add the jna.jar file via Android Studio (build.gradle, dependencies{...}) "implementation files('libs/jna-5.12.1.jar')" or if I directly add it with gradle using "implementation 'net.java.dev.jna:jna:5.12.1'".
I also set the source path in android{...} to
SourceSets{
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
I placed the jna.jar inside of android/app/libs and added the missing android-* (e.g. android-aarch64) folder with their libjnidispatch.so. I got the android-aarch64.jar files from the github repository, and changed them to folders.
I also added the android-* folders to android/app/src/main/jniLibs with their full names and only with the architecture (e.g. android-aarch64 and aarch64).
My custom .so file is also located in this folder "android/app/src/main/jniLibs".
Do I have to set any other path?
Matthias Bläsing
unread,
Oct 27, 2022, 12:48:12 PM10/27/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jna-...@googlegroups.com
Hi,
using JNA on android is already covered on stackoverflow:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to jna-...@googlegroups.com
Am Freitag, dem 28.10.2022 um 00:25 -0700 schrieb Flippy:
> the @aar trick after implementation files ('libs/jna.5.12.1.jar@aar')
> did the trick for me, thank you!
> Now my library can't be found even if I use
> System.setProperty("jna.library.path", "/absolute/path/to/so")
> and using
> SourceSets main.jniLibs.srcDirs ['src/main/jniLibs'].
>
> I placed my .so to app/src/main/jniLibs/. In this folder I placed the
> .so and I also have folders for each architecture "aarch64" and
> "android-aarch64" consisting the so. Also I placed the all of the
> contents to app/libs.
>
> "Unable to load library 'testlib':
> dlopen failed: library "libtestlib.so" not found
> dlopen failed: library "libtestlib.so" not found
> dlopen failed: library "libtestlib.so" not found
> Native library (android-aarch64/libtestlib.so) not found in resource
> path (.)
This is not a JNA question. Figure out how to properly bundle a native
library on android. On android loading from classpath WILL FAIL. You
have to bundle the native library correctly.