1. Download Cocos2D-android library from Github
  2. Download Eclipse IDE for Java Developers
  3. Download the Android SDK , and Install the Android Developer Tools (ADT Plugin) by following this tutorial by Google
  4. Setup an Android Virtual Device (AVD) Simulator for testing. In Eclipse, choose Window > Android SDK and AVD Manager. Select Virtual Devices in the left panel.Click New.The Create New AVD dialog appears.Type the name of the AVD, such as “my_avd”.Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.1) you want to run on the emulator. It is recommended to use Android 2.1 and above for Cocos2d development. Detailed information on testing android applications using an actual android device such as an android tablet pc or mobile phone can be found here.

Setting Up Cocos2d Source Package

After downloading Cocos2d (, copy the cocos2d-android folder to your Eclipse workspace and import it as an Android project. The cocos2d-android folder is a full fledged android project with sample code that demonstrates the capabilities of the cocos2d engine. It may be used as a library project (referenced by other full android projects) or run as a standard Android Project. The src folder contains all the java classes for each function within the game engine. To import, use the following steps:

  • File > Import > Existing Project into workspace
  • Select root directory > Browse . Select your workspace folder and locate the cocos2d-android folder in it

  •  Now you should have your package explorer look like this


Running the Cocos2D Source Package

  • To run the project as an android app you must deselect the library option.Right Click on the project > Properties > Android (on the left) > Deselect the “Is Library” Options. Click Apply and OK.
  • Delete the cocos2d-android.jar file in the bin directory. Failing to delete this file will result in compile errors (both the src files and the .jar file contain the same classes … its like two files with the same name trying to reside in the same directory … a no no).
  • Right click on project > Run As > Android Application
  • You may be prompted to create an appropriate target AVD (simulator) to run your application. Follow the prompt .

You should have your simulator running and looking like this…

Congratulations, you have set up Cocos2D for Android. In order to identify which part of the code is responsible for the different sections of the sample code running above, you can review the project code under package explorer.

src > org.cocos2d.tests


For Next Part Click here:

Android Game Development Using Cocos2d part-3