Android on Windows 10 - Cocos2d-x Install Fixes

Hello everyone,

I spent the past three days trying to get a Cocos2d-x android project to build on my new Windows 10 machine for Android Studio. I had to fix the following issues in order to build and run my project:

JDK Version:

In my experience, the build requirements were spot on except for the JDK version. I tried using the latest JDK version (v12.0.1) when attempting to compile my Cocos2d-x project and it produced a build error. The same happened for JDK v1.6. In the end, I installed the JDK v1.8.0, created a JAVA_HOME Environment Variable, then attempted to compile my Cocos2d-x project and it built successfully!

environment_variable

Gradle Plugin Update:

When I opened my project for the first time in Android Studio the following dialog box appeared.
update

I selected Update and proceeded to build my project.

Merge Assets Error:

After a successful build I received the following warning:

In order to fix it I had to open my App’s proj.android file and update the variant.mergeAssets.doLast line as shown here:

variant_before

Update that line to the following to get rid of the warning:

variant_after

Project Properties:

I had to open the gradle.properties file and remove the default setting for PROP_APP_ABI and set it to x86

app_abi

Build Variants:

The last thing I did was to update the Build Variant for my project CrabApple to debug-x86

build_variants

Final Thoughts:

It was a pain in the butt to get up and running with Cocos2d-x which sucked since this is my first time using a framework for building 2d games. I’m sure this process will continue to get better and I hope that my post will help others who run into the same roadblocks I did.

Thank you for posting this. I’ll be happy to test this out on a clean Windows 10 system.

Android development always seems like a challenge to me. Each update something changes.

2 Likes

Why did you do this? If you’re working with Android Studio, then I am assuming that you are developing for Android, in which case armeabi-v7a and arm64-v8a are eventually required architectures to build for, especially if you want to test on most Android devices. Targeting x86 is only if you want to run it on rare x86 Android devices (perhaps a Chromebook?), or in an Intel x86 Android simulator.

If you’re just setting up to get started with Cocos2d-x development, then given you’re working with Windows 10, you may as well do your development in Visual Studio 2019, and save yourself time and headaches. The VS IDE is much more responsive, and the overall workflow is much more pleasant than when working with Android Studio.

Once you have your game/app running as you want it in VS, then you could simply switch over to Android Studio and build it there for your particular purposes.