views:

408

answers:

1

I m working on android application in which I used JNI for native c code. I build this application on android 2.0 version and ndkr3 and it works fine.

Now when I changed the android sdk version 1.5 and api version 3 I faced problems of unable to open library libtest_demo.so.

05-13 16:54:23.603: INFO/dalvikvm(1211): Unable to dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so): Cannot find library

I put the libtest_demo.so file at the same place /data/data/org.abc.test_demo/lib/libtest_demo.so but still the same problem arises.

In my java file I called native libraries like,

 System.loadLibrary("abc_jni");
 System.loadLibrary("test_demo");

And from the logcat I seen both libraries used same memory address.

This is logcat output

05-13 17:56:15.732: DEBUG/dalvikvm(9897): Trying to load lib /data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.732: DEBUG/dalvikvm(9897): Added shared lib /data/data/org.abc.test_demo/lib/libabc_jni.so 0x437317f8
05-13 17:56:15.742: DEBUG/dalvikvm(9897): Trying to load lib /data/data/org.abc.test_demo/lib/libtest_demo.so 0x437317f8 
05-13 17:56:15.752: INFO/dalvikvm(9897): Unable to dlopen(/data/data/org.abc.test_demo/lib/libtest_demo.so): Cannot find library
A: 

This error almost always says "Cannot find library" and there can be many reasons for this. What is annoying is that in most cases it is not the missing library but something else. Reasons I have stumbled upon:

  • library is missing from the directory (obviously),
  • library that is dynamically linked with your library is missing,
  • system library versions on the device/emulator that your library uses differ with those that you were linking against in compile time (missing symbols, etc.)

I have described a method that worked for me when resolving an issue with library that was working fine on emulator and was failing to load on Nexus One, maybe this will help you: http://mpigulski.blogspot.com/2010/09/debugging-dlopen-unsatisfiedlinkerror.html

Maciej Pigulski