get up and running with cocos2d-x 3.0 alpha 1 android on mac os x mavericks

one of cocos2d-x‘s strengths is that it’s a cross-platform framework. one of those platforms is google’s android.

i have never done any android development before. luckily, the documentation for the initial setup of both the android sdk/ndk, and cocos2d-x, is pretty decent. however, there were a few wrinkles due to version changes in both the os (mavericks) and framework (3.0 alpha 1).

this is not a tutorial: i’m not going to go into step-by-step detail of what i did because everything went pretty much as documented. i’m sharing a few things someone might run into when setting up with an environment like mine.

intro

the cocos2d-x/android development requirements can be divided into two major categories:

  1. installing the android sdk and ndk (native development kit)
  2. configuring them for cocos2d-x

installing the android sdk and ndk

configuring for cocos2d-x

environment variables

i pretty much followed the steps on this cocos2d-x wiki page for setting up a multiplatform project, which includes making the following edits to my .bashrc file:

updating the android project

the wiki page walks you through this pretty well. there are two minor variations due to cocos2d-x 3.0 alpha 1:

i then followed the rest of the documentation on that page and got the cocos2d-x hello world project running in both the emulator and on an actual hardware device. success!

a note on android emulation

the android emulator that comes with the android sdk is slow. a product/service called genymotion makes a faster one. however, it’s not so much an emulator as a simulator: much like the iOS simulator, the genymotion vm runs x86 code.

this is great if you’re writing java code, but trying to run native arm code on it will not work. i don’t know how to make the android toolchain build x86 code yet, so for now i’ll be sticking to google’s emulator and real hardware.

a note on eclipse

at the moment, i have not been able to build a cocos2d-x 3.0 alpha 1 project inside eclipse (command line builds work fine). so far, the only information i can find about using eclipse for cocos2d-x is for pre-3.0 versions, and doesn’t seem to work for 3.0 alpha 1.

comments

comments powered by Disqus