0

I am attempting to add a third-party library to my Android app. It utilizes a .jar file and a .so file. This is a pre-built .so file (i.e. not built specifically for the Android app) - which I know will provide me with plenty of problems down the road. I do NOT have access to the source files for the .jar or .so files!

I am attempting to dynamically load the library via a call to System.loadLibrary("foo");. Currently, when attempting to run the app, it crashes with the UnsatisfiedLinkError: Library foo not found. I have the .so file in both the libs/ and the libs/armeabi file in my project.

Am I chasing after a ghost here? I am trying to determine if what I'm after is even feasible. I have no native code that I'm referencing - all my function calls are to the .jar file that is, as I understand it, backed by the .so file. I have not run the Android.mk file as I'm not compiling anything - the .so file is already provided. I could really use some advice as to what direction to proceed from here.

BigJim
  • 23
  • 6
  • You might want to have a look at some of the ideas discussed here: http://stackoverflow.com/questions/6209070/android-load-native-library – jimkberry Aug 05 '11 at 13:34

1 Answers1

0

It's possible that the base name given to System.loadLibrary() is expanding to a file (or path) name different than that of the actual prebuilt library. Logcat should show you exactly what it is trying to load. You could also use System.load() with a full path/file name instead of System.loadLibrary() - though you really should get it working with the later.

While I think it would generate a different error message, it's also possible that the .so is not android compatible - it must not only be for a compatible processor type and abi, but not depend on any dynamic libraries (such as a non-bionic libc) not installed on the device.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • That is definitely a possibility. I think you are right as to the .so not being compatible. Heck for all I know it probably isn't even JNI compatible! I've done a lot of reading on this, and I believe that ultimately, unless you build your source files specifically for the Android, utilizing the ndk-build script, it simply won't work. – BigJim Aug 06 '11 at 15:46
  • @BigJim I do think it would be worth looking into in more detail - dumping out the dependencies of the .so, verifying it's actually getting installed, and trying the explicit path. At minimum it would be an educational experience. – Chris Stratton Aug 07 '11 at 12:36