Search code examples
cocos2d-xgame-engine

Cocos2d-x project crashes on Runtime: ClassLoader referenced unknown path: /data/app/org.cocos2dx.MyFirstGame-1/lib/x86 in Android Studio emulator


I'm using Windows 10 and Cocos2dx-13.1. I was able to build my project file using

cocos compile -p android 13 -m debug

But when I run it on Android Studio emulator, the emulator crashes and I get this error logs:

  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)

I think this error is the root of the problem but I've no idea how to fix it:

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

Solution

  • I read you're using Android Studio. Android Studio doesnt have support for Cocos2d-x as of now. You cannot simply rely on their emulator to run your APK. I suggest testing on a real device or use Bluestacks Emulator.

    I think this is highlighted in this question.