Cocos2d-x 项目在运行时崩溃:ClassLoader 引用了未知路径:/data/app/org.cocos2dx.MyFirstGame-1/lib/x86 在 Android Studio 模拟器中
Cocos2d-x project crashes on Runtime: ClassLoader referenced unknown path: /data/app/org.cocos2dx.MyFirstGame-1/lib/x86 in Android Studio emulator
我正在使用 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
发生此错误是因为您未针对 x86 架构编译 cocos2d-x。
在 Application.mk 文件中更改为:
APP_ABI := armeabi armeabi-v7a x86
然后重新编译测试
我了解到您正在使用 Android Studio。 Android Studio 目前不支持 Cocos2d-x。您不能简单地依靠他们的模拟器来 运行 您的 APK。我建议在真实设备上进行测试或使用 Bluestacks 模拟器。
我认为这已在 this question 中突出显示。
我正在使用 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
发生此错误是因为您未针对 x86 架构编译 cocos2d-x。
在 Application.mk 文件中更改为:
APP_ABI := armeabi armeabi-v7a x86
然后重新编译测试
我了解到您正在使用 Android Studio。 Android Studio 目前不支持 Cocos2d-x。您不能简单地依靠他们的模拟器来 运行 您的 APK。我建议在真实设备上进行测试或使用 Bluestacks 模拟器。
我认为这已在 this question 中突出显示。