Search code examples
androidandroid-ndkjava-native-interface

Couldn't load libfoo: findLibrary returned null


I did everything "right":

  1. Created my JNI module with LOCAL_MODULE := libfoo in jni/Android.mk

  2. Called System.loadlibrary("libfoo")

  3. Declared the correct signature for the method and even double-checked it with javah

but still got an UnsatisfiedLinkError exception with the message:

Couldn't load libfoo: findLibrary returned null


Solution

  • Apparently the loadLibrary method prepends "lib" automatically so the proper way to load a filename such as "libfoo.so" is by calling System.loadLibrary("foo").

    I learned this the hard way, so you wouldn't have to.