Android System.loadLibrary throwing UnsatisfiedLinkError

Hey all,

Our game is live in the Android store and we’re getting some crash reports from Google:

java.lang.ExceptionInInitializerError
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1409)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3683)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
    Caused by: java.lang.UnsatisfiedLinkError: Couldn't load game: findLibrary returned null
    at java.lang.Runtime.loadLibrary(Runtime.java:429)
    at java.lang.System.loadLibrary(System.java:554)
    ...

It appears to be happening with this call in our main Activity:

static {
    System.loadLibrary("game");
}

The app crashes immediately on startup when this happens. We can’t reproduce this in any local environment. I’ve searched around online and there’s a number of possible reasons for this. It appears to happen on all devices and all versions of Android. It can also happen if the app is corrupted during install from Google Play.

I know the System call is for loading the JNI bindings. Are there any special compiler flags we need to add in our Android.mk? A lot of people were able to solve these problems by tweaking their makefile a bit. Just wondering if any one else ran in to this.

Thanks,

— Joel

I got same problem. :frowning:

Actually this problem happens on emulator, not on device.

Anyone help us ?

Does this thread refer to Javascript Binding??

Yes. It’s related to JavaScript bindings in Android builds. You need the JNI calls in order to use the bindings.

Could you make a demo to reproduce this issue? That will be easier for use to debug. Thanks.

Check it: http://www.cocos2d-x.org/forums/20/topics/38931