Using Cocos - issue with Android build

Hi,

I’m very new to game development, I’m just about to start developing my first game.

I downloaded and installed the latest Cocos installer which included cocos2d-x 3.10. I used it to create a new project. I used a pre-compiled option first which seemed to create both iOS and Android projects.

I was able to open and run the iOS project in the xCode/simulator successfully. When I tried to open the Android project, Cocos told me it only works with source code version of the project (not pre-compiled). So I created another project, this time with source code option. Again, I was able to run the iOS version just fine.

I was able to open the project in Android Studio this time, everything seemed to work fine, but when I tried to run the app in the Android emulator and actual Android device, I get “Unfortunately, libcocos2dx has stopped”.

I guess I’d need to compile the actual Cocos source before trying to run the Android version but I’m not sure how to do that. Any help much appreciated.

Thanks

Hello @NoviceCode

Strangely, I don’t see the issue which you have reported with the latest Cocos.
I am not sure for how android studio works, haven’t tried yet.

So, please follow these steps with your precompiled project -

  1. Go to the project directory in terminal.
  2. Run this command - cocos compile -p android
    If this commands builds successfully, you will see BUILD SUCCESSFUL at the end of the build.
    else there might be issues somewhere with something.

If the build is successful, it should run fine in your device.

Let me know by doing these steps, all I basically ask you do do is compile through the terminal

Hi,

thanks for the comment, I tried to compile from command line based on your instruction but it doesn’t compile successfully. There seems to be something messed up in my setup. I used to have cocos2d-x 3.9 installed and I was able to run both iOS and Android versions with no problem.

Now that I installed Cocos (bundled with cocos2d-x 3.10) Android stuff stopped working. Might have something to do with NDK potentially.

Would be interesting to know if someone has been able to use the Cocos (bundled with 3.10) and successfully run the Android project in Android Studio.

Please run the setup.py once again and check whether all the paths are correct or not.
possibly, if those values changes, then also issue might come.

Hi,

I ran the setup.py and everything seemed to be ok as far as I can tell, all the required components were found on path.

Not sure yet but I suspect that there is something wrong with the NDK version. When I started the Android Studio it asked if I wanted to update all the related components which I did. It also updated the NDK and there might be something wrong with that.

EDIT: I figured out the problem. Android Studio indeed updated the NDK to version 11 which doesn’t work. Luckily I still had the NDK 10 around which I installed after removing version 11. After this I was able to compile the Android project and generate an APK from command line. Worked like a charm in my phone. I will also see if I can make it work directly from Android Studio, that would be nice.

EDIT2: Cannot get the Android Studio part working. I’m able to compile the Android version from command line but not able to generate a working APK from Android Studio. I looks like the libcocos is missing from the APK hence it crashes both on emulator and device.

So using NDK ver 11.0.0 is not recommended?

We don’t officially support it yet.