The workflow to run the Cocos2D-x projects on Android is as follows:

  1. Open the project in Eclipse (File > New Android Project > Create project from existing source, select the android folder from your project folder)
  2. Open a terminal and navigate to the android folder, run ./build_native
  3. When that’s done, switch back to Eclipse and clean the project (Project > Clean)
  4. Right click the project and select Run As > Android Application

At this point if your Android device is connected, the app should automatically be deployed to it if the API versions match.

If you do not have an Android device, now’s a good time to configure a new Android Virtual Device (AVD).

Every time you modify the source files you are going to need to run build_native (step 2) in the terminal and then clean the project in Eclipse (step 3). Cleaning the project will force Eclipse to refresh the bundle files and take into account the newly compiled code when creating the game APK.

By default, the wizard will not set the min SDK version in the manifest file. It is a good idea to have that set so open up the AndroidManifest.xml file and set it to the oldest version that you want to support. I usually go with SDK version 7 (Android 2.1-update1).

If you want to manually edit the XML file you will need to add the following line right above the </manifest> tag:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="7"></uses-sdk>

Have fun!

Share this article

Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *