1

There is a very weird situation. I am using this project in my Android Application. To use it, I have to include JNA in my project. SO I downloaded jar file of JNA from here. All is good to go. BUT when I ran the project, it gave me UnsatisfiedLinkError for libjnidispatch.so file. I downloaded my desired architecture from this link and re-ran the project. This error is gone and here comes the new one.

 Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'iengine_ansi_iso': Native library (android-arm/libiengine_ansi_iso.so) not found in resource path (.)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:303)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:427)
at com.sun.jna.Library$Handler.<init>(Library.java:179)
at com.sun.jna.Native.loadLibrary(Native.java:569)
at com.sun.jna.Native.loadLibrary(Native.java:544)
at com.foreepay.fingerprintextraction.ansiiso.AnsiIso$AnsiIsoNative.<clinit>(AnsiIso.java:55)
at com.foreepay.fingerprintextraction.ansiiso.AnsiIso.isoCreateTemplate(AnsiIso.java:500)
at com.foreepay.fingerprintextraction.fingerprint.core.ProcessImage.doInBackground(ProcessImage.java:163)
at com.foreepay.fingerprintextraction.fingerprint.core.ProcessImage.doInBackground(ProcessImage.java:39)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
at java.lang.Thread.run(Thread.java:761) 

I tried to do exactly the same in this case. Downloaded the required file from here, put it in folder (src/main/jniLibs/armeabi-v7a), but no luck. Since then I tried every possible way to add *.so file in Android Studio Project, but it failed every time.

These are the links which I have tried to add .so file but every one has almost the same solution, which is not working in my case OR maybe my case is not their case.

  1. Adding a .so file in Android Studio
  2. How to include *.so library in Android Studio?
  3. Android NDK: how include *.so files in AndroidStudio

And some more.

I am still unable to find the cause. Here is a code block which is causing the issue.

final AnsiIsoNative INSTANCE = (AnsiIsoNative) Native.loadLibrary("iengine_ansi_iso", AnsiIsoNative.class);

Where Native is a JNA class.

Any help is appreciated.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Waqas Ahmed Ansari
  • 1,683
  • 15
  • 30
  • Run JNA with `-Djna.debug_load=true` to see where JNA is looking for the resource. It checks a few different places. Then either make sure your resource is found in that path, or provide an absolute file path to the VM. Android is kind of a special case since the native libraries are integrated with the project in a different way than other systems. – technomage Jan 20 '18 at 06:01
  • @technomage I tried setting up `-Djna.debug_load=true` by going in Help>Edit Custom VM Options on Android Studio. Restarted Android Studio but still JNA doesn't show the full path in error. – faisal00813 Apr 19 '18 at 07:49
  • Still stuck on the same error mentioned by @waqas-ahmed-ansari. – faisal00813 Apr 19 '18 at 07:49
  • IIRC, you can't dynamically load shared libraries on android with a custom path; they are only available if built with the project, and then they appear on the system library load path. – technomage Apr 28 '18 at 13:41
  • Add some code to verify that `System.getProperty("jna.debug_load")` is actually being set. I believe that it should find the library when it attempts a load without any explicit path. For reference, see [JavaDoc for NativeLibrary](https://java-native-access.github.io/jna/4.5.0/javadoc/index.html?com/sun/jna/NativeLibrary.html) – technomage Apr 28 '18 at 13:43

0 Answers0