Cocos2D-x 3.8.1 and Android Studio (can't run my project)

First of all, posting a topic in this forum is very hard and confusing. I didn’t see “new thread” or “ask question” button or any other buttons to post a new thread. After I spent few hours on this I figured out there are keyboard shortcuts so I pressed C on my keyboard now I can post my new thread. very struggling.

Anyway. I can’t use Android Studio with my cocos2d-x 3.8.1. I opened Android Studio and imported “proj.android-studio” folder to the studio. But I can’t run it, it gives me a bunch of errors:

FATAL EXCEPTION: main
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: Process: my.package.name, PID: 23001
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.acrstudios.eternalcastle-1/base.apk”],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn’t find “libcocos2dcpp.so”
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at java.lang.Runtime.loadLibrary(Runtime.java:366)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:988)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:288)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:303)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6865)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2434)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java:153)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5374)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
10-03 14:42:04.806 23001-23001/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

help me please. thanks in advance

Compiling with Android Studio is currently not supported. So you have to use cocos console to compile your code.

cocos compile -p android --android-studio

After executing this command you should be able to run your game from android studio.

2 Likes

Thanks it worked