Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.loadLibrary() error

I successfully cross-compiled a c++ library with the android ndk-Standalone toolchain then, i created a new android application project into Eclipse and when i put mylib.so into the jni folder and execute ndk-build commands it works fine

Prebuilt       : mylib.so <= jni/
Install        : mylib.so => libs/armeabi/mylib.so

But when adding

static{
  System.load("/data/data/my_package/lib/mylib.so");
}

i got an error in the logcat saying

   AndroidRuntime
   Caused by: java.lang.UnsatisfiedLinkError: Cannot load library:
   reloc_library[1306]:      36 cannot locate 'xmlCleanupParser'...``

i googled it but didn't find any way to solve this problem.

like image 646
Hadj Ali Oussama Avatar asked Mar 04 '13 15:03

Hadj Ali Oussama


2 Answers

People mostly forgot cut "lib" prefix form library name. So if you have "libusb.so" your code must be System.loadLibrary("usb")...

like image 113
cevdet Avatar answered Sep 28 '22 11:09

cevdet


I recently encountered the same error. After trying out dozens of suggestions from SO, I finally figured out that the error was in my native code. even though android ndk had compiled it without any issues / warnings.

Try writing a simple main function to test your native code and compile with g++/gcc (or something similar) to check for errors.

I know its too late for the asker, but hope someone else finds this useful.

like image 25
codeAnatomist6 Avatar answered Sep 28 '22 12:09

codeAnatomist6