Twig Technology

[...] incredibly interested in all the things you could do with twigs.

Android NDK Shared Libraries

| Comments

This morning, I got stumped by the Java/NDK integration. I was trying to add another shared library (Lua) to a project, and kept getting these dynamic linker error messages:

I/ActivityManager( 1386): Start proc for activity pid=25826 uid=10087 gids={1015}
W/dalvikvm(25826): Exception Ljava/lang/UnsatisfiedLinkError; thrown during Lorg/libsdl/app/SDLActivity;.<clinit>
W/dalvikvm(25826): Class init failed in newInstance call (Lorg/libsdl/app/SDLActivity;)
W/dalvikvm(25826): threadid=1: thread exiting with uncaught exception (group=0x40020ac0)
E/AndroidRuntime(25826): FATAL EXCEPTION: main
E/AndroidRuntime(25826): java.lang.ExceptionInInitializerError
E/AndroidRuntime(25826):        at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(25826):        at java.lang.Class.newInstance(
E/AndroidRuntime(25826):        at
E/AndroidRuntime(25826):        at
E/AndroidRuntime(25826):        at
E/AndroidRuntime(25826):        at$2300(
E/AndroidRuntime(25826):        at$H.handleMessage(
E/AndroidRuntime(25826):        at android.os.Handler.dispatchMessage(
E/AndroidRuntime(25826):        at android.os.Looper.loop(
E/AndroidRuntime(25826):        at
E/AndroidRuntime(25826):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(25826):        at java.lang.reflect.Method.invoke(
E/AndroidRuntime(25826):        at$
E/AndroidRuntime(25826):        at
E/AndroidRuntime(25826):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(25826): Caused by: java.lang.UnsatisfiedLinkError: Library main not found
E/AndroidRuntime(25826):        at java.lang.Runtime.loadLibrary(
E/AndroidRuntime(25826):        at java.lang.System.loadLibrary(
E/AndroidRuntime(25826):        at<clinit>(
E/AndroidRuntime(25826):        ... 15 more
W/ActivityManager( 1386):   Force finishing activity

What it was was that my Activity (which is a small java stub) needed to call System.loadLibrary(“Lua”); to load that new library. How is that related to the error message? I have no idea.

Sigh. Sometimes missing a single line will cost you half a day.