Caused by: java.lang.UnsatisfiedLinkError: Cannot load library

when I tried to package an old cocos2dx NDK project, I encountered this problem, apk could be exported but crashed when start running it.

Here is the log I get from eclipse logcat:

FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1521]:   492 unknown reloc type   160 @      (60218)
	at java.lang.Runtime.loadLibrary(Runtime.java:434)
	at java.lang.System.loadLibrary(System.java:554)
	at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:246)
	at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:260)
	at org.cocos2dx.phonegame.PhoneGameActivity.onCreate(PhoneGameActivity.java:83)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
	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:880)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
	at dalvik.system.NativeStart.main(Native Method)

First, I clean the project and rebuild it. but the problem is still there.

Then, I find another project and rewrite the Android.mk file under jni folder, but still not ok.

I don't think it's the problem with ndk version, because other project with the same ndk could run perfectly.

At last, I rewrite the Application.mk file under jni folder, this time the ndk compiler rebuild the libc++_static.a and everything is ok.

In a word, this problem in my case is caused by old wrong libc++static.a lib, and only clean the project and rebuild cannot update it.


Solution: Change the Application.mk and force the libc++static.a to be rebuild.
(ps:Maybe delete the obj folder could also make it.)

你可能感兴趣的:(Cocos2d-x,Android,NDK)