Cocos2d-x项目在运行时崩溃:ClassLoader引用了未知路径:Android Studio模拟器中的/data/app/org.cocos2dx.MyFirstGame-1/lib/x86

时间:2016-10-18 15:26:53

标签: cocos2d-x game-engine

我正在使用Windows 10和Cocos2dx-13.1。我能够使用

构建我的项目文件
cocos compile -p android 13 -m debug

但是当我在Android Studio模拟器上运行它时,模拟器崩溃了,我收到了这个错误日志:

  ClassLoader referenced unknown path: /data/app/org.cocos2dx.MyFirstGame-1/lib/x86
    10-18 13:37:07.875 10364-10364/org.cocos2dx.MyFirstGameD/AndroidRuntime: Shutting down VM
    10-18 13:37:07.875 10364-10364/org.cocos2dx.MyFirstGameE/AndroidRuntime: FATAL EXCEPTION: main
                                                                             Process: org.cocos2dx.MyFirstGame, PID: 10364
                                                                             java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/org.cocos2dx.MyFirstGame-1/base.apk"],nativeLibraryDirectories=[/data/app/org.cocos2dx.MyFirstGame-1/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libMyGame.so"
                                                                                 at java.lang.Runtime.loadLibrary0(Runtime.java:972)
                                                                                 at java.lang.System.loadLibrary(System.java:1530)
                                                                                 at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:248)
                                                                                 at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:264)
                                                                                 at android.app.Activity.performCreate(Activity.java:6664)
                                                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                                 at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                                 at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                 at android.os.Looper.loop(Looper.java:154)
                                                                                 at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                                 at java.lang.reflect.Method.invoke(Native Method)
                                                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

我认为这个错误是问题的根源,但我不知道如何修复它:

ClassLoader referenced unknown path: /data/app/org.cocos2dx.MyFirstGame-1/lib/x86

2 个答案:

答案 0 :(得分:0)

发生此错误是因为您没有为x86架构编译cocos2d-x。

Application.mk 文件中更改为

APP_ABI := armeabi armeabi-v7a x86

然后重新编译并测试。

答案 1 :(得分:0)

我读到你正在使用Android Studio。截至目前,Android Studio并不支持Cocos2d-x。你不能简单地依靠他们的模拟器来运行你的APK。我建议在真实设备上进行测试或使用Bluestacks Emulator。

我认为这在this question中突出显示。