Cocos2d-x in Android

How to set up in Mac


  • Android SDK(ver 23)
  • Android NDK(r9d)
  • Cocos2d-x(v3.2)
  • ant
  • python

If you haven’t install, you need to install ant, and python using brew etc…
Android SDK, NDK, cocos2d-x should be decompressed.

** android-ndk64-r10 doesn’t work so far(2014/08/26) **

Set environment vars

Details Cocos2d-x
Go to your cocos2d-x root and type


The command asks ant, sdk, ndk home.
These parameters are written in .bash_profile.
If you forgot path and skip when running command, you set these parameters in .bash_profile

Create new project

cd your cocos-2d-x root and type

cocos new GameSample -p com.atmarkplant.gamesample -l cpp -d /Users/dj110/Documents/cocosproject

GameSample is your project name, com.atmarkplant.gamesample is your package name,
-d xxx is your project root.

Import and Eclipse setup

You need to import project which is generated by above command.
You can see in your project named

** We nee dto install android-sdk-r23, annotion.jar is missing in r22 **
For Eclipse you need Environment setting
“Properties” -> “C/C++” -> “Build” -> Environment
And add NDK_ROOT as key and your ndk root directory path as value.

cocos2d-x project

** I skipped android eclipse setting for SDK and NDK.

* You also need to import libcocos2dx to resolve dependencies.

Run project

“Debug” -> “Android Application”
You can run application.

ndk result