I’m using prebuilt libs (libsox.so et al) and I’m using a small test file for the JNI interface (sox-test-jni.so). I’m trying to load “sox” and “sox-test-jni” via System.loadLibrary and I’m getting an UnsatisfiedLinkError at run-time.
I previously built libsox.so et al with NDK.
When I run ndk-build, everything seems fine and all required files are put in into libs/armeabi-v7a/
When running my Java app on a phone, the error is:
Cannot load library: link_image[1963]: 1413 could not load needed library 'liblpc10.so' for 'libsox.so' (load_library[1105]: Library 'liblpc10.so' not found)
So apparently it finds libsox.so just fine but can’t find liblpc10.so, which lives right next to it.
These are the libs in my APK file – in libs/armeabi-v71/
libffmpeg.so
libFLAC.so
libfmemopen.so
libgsm.so
liblpc10.so
libmad.so
libmp3lame.so
libogg.so
libplayer.so
libpng.so
libsmr.so
libsmrx.so
libsndfile.so
libsox.so
libsox-test-jni.so
libvorbis.so
libvorbisenc.so
libvorbisfile.so
libwavpack.so
Here’s my Android.mk for the JNI stuff.
http://pastebin.com/raw.php?i=dcSijYSv
Here’s my Java:
package roman10.ffmpegTest;
import android.app.ListActivity;
import android.widget.AbsListView;
import android.widget.ListView;
public class VideoBrowser extends ListActivity implements ListView.OnScrollListener {
//load the native library
static {
System.loadLibrary("sox");
System.loadLibrary("sox-test-jni");
}
@Override
public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
}
Looks like I need to tell explicitly Java to load any dependencies. It won’t figure them out on it’s own even though it knows it wants “liblpc10.so” it won’t automatically load it.