今天接一个安卓的sdk的时候出现了这个问题,具体是调用这个方法是出现的

protected void onLoadNativeLibraries() {
    try {
        ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
        Bundle bundle = ai.metaData;
        String libName = bundle.getString("android.app.lib_name");
        System.loadLibrary("cocos2dcpp");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

打印出的错误日志是这个

11-08 13:27:43.379: E/AndroidRuntime(14630): FATAL EXCEPTION: main
11-08 13:27:43.379: E/AndroidRuntime(14630): Process: org.cocos2dx.Caribbean.JD, PID: 14630
11-08 13:27:43.379: E/AndroidRuntime(14630): java.lang.UnsatisfiedLinkError: Couldn't load cocos2dcpp from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.cocos2dx.Caribbean.JD-1.apk"],nativeLibraryDirectories=[/data/app-lib/org.cocos2dx.Caribbean.JD-1, /vendor/lib, /system/lib]]]: findLibrary returned null
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at java.lang.Runtime.loadLibrary(Runtime.java:365)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at java.lang.System.loadLibrary(System.java:526)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at org.cocos2dx.Caribbean.Caribbean.onLoadNativeLibraries(Caribbean.java:95)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at org.cocos2dx.Caribbean.Caribbean.onCreate(Caribbean.java:85)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.Activity.performCreate(Activity.java:5295)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2419)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.ActivityThread.access$800(ActivityThread.java:155)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.os.Handler.dispatchMessage(Handler.java:110)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.os.Looper.loop(Looper.java:193)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at android.app.ActivityThread.main(ActivityThread.java:5409)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at java.lang.reflect.Method.invokeNative(Native Method)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at java.lang.reflect.Method.invoke(Method.java:515)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:859)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:675)
11-08 13:27:43.379: E/AndroidRuntime(14630): 	at dalvik.system.NativeStart.main(Native Method)

最后在stackoverflow上面找到一个可以解决我这个情况的问题解答

需要确定项目里面是不是libcocos2dcpp这个名字,如下图

屏幕快照 2015-11-08 16.44.08.png

在proj.android/jni/Android.mk里面

LOCAL_MODULE_FILENAME := libcocos2dcpp

我的原因就是这个名字被修改过,所以是找不到了。

同时还记得在项目的AndroidManifest.xml文件里面修改相应的字段

 <meta-data android:name="android.app.lib_name"  android:value="cocos2dcpp" />

解答原文链接:

http://stackoverflow.com/questions/23757578/unsatisfiedlinkerror-couldnt-load-cocos2dcpp-findlibrary-returned-null


☟☟可点击下方广告支持一下☟☟

最后修改:1970 年 01 月 01 日
请我喝杯可乐,请随意打赏: ☞已打赏列表