Search code examples
javaandroidandroid-studiojna.so

Load *.so with JNA on Android Studio


I'm working on a Android Service, which communicate with hardware & applications. I am using a native library to access hardware (libTemp.so). I tested this lib on windows & ubuntu with a java program using JNA.

temperatureHardware = (TempNative) Native.loadLibrary("libTemp.so", TempNative.class);

This is how I connect the *.so lib with the TempNative object. When I try this on Android, I get as follow.

W/linker: /data/app/com.example.kube.tempsystemservice-YUkS9udICA7GsJhTA8fG4A==/lib/arm/libjnidispatch.so: is missing DT_SONAME will use basename as a replacement: "libjnidispatch.so"

Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'libTemp.so': Native library (android-arm/liblibTemp.so.so) not found in resource path (.)

is this because service can't find the lib file?

I add the lib file as follow...

lib file location image


Solution

  • try using the library name without the extension.

    temperatureHardware = (TempNative) Native.loadLibrary("libTemp", TempNative.class);