This is a guide to setup the cocos2dx for android in Windows. 1. Download Android SDK: Instead of downloading only SDK you can download the ADT Bundle which has a collection of Android SDK, Eclipse and Android Plugin for Eclipse. Download the latest version from http:developer.android.comsdkindex.html. Extract ADT. I extracted in my E: Drive. My location of the ADT will beE:adtbundlewindowsx86_6420130717. My location of the SDK will be E:adtbundlewindowsx86_6420130717sdk. Also remember to update the SDK.Select the latest version of API and also the Android 2.2 (API 8).
COCOS2D-X Installation Guide This is a guide to setup the cocos2d-x for android in Windows Download Android SDK: Instead of downloading only SDK you can download the ADT Bundle which has a collection of Android SDK, Eclipse and Android Plugin for Eclipse Download the latest version from http://developer.android.com/sdk/index.html Extract ADT I extracted in my E:\ Drive My location of the ADT will beE:\adt-bundle-windows-x86_64-20130717 My location of the SDK will be E:\adt-bundle-windows-x86_64-20130717\sdk Also remember to update the SDK.Select the latest version of API and also the Android 2.2 (API 8) Download NDK from http://developer.android.com/tools/sdk/ndk/index.html I am using a 64 Bit Windows OS So, I downloaded the version android-ndk-r9-windows-x86_64.zip Extract the NDK to your C:\ Drive I extracted mine at E:\android-ndk-r9 Download and install Cygwin from http://www.cygwin.com/install.html Cygwin is a program that enables you to get a Linux feeling on Windows You can install certain packages on Cygwin and have a minimal Linux like environment Install Cygwin When asked to select packages, search for the below packages and install them: autoconf, automake, binutils, gcc-core, gcc-g++, gcc4-core, gcc4-g++, gdb, pcre, pcre-devel, gawk, make Note: Select the GUI version of make as well otherwise you will not be able to build your project using NDK Download JDK from http://www.oracle.com/technetwork/java/javase/downloads/jdk7downloads-1880260.html No matter if you system is 32 bit or 64 bit, you need to download only the 32 bit version Install Java in C:\Java Download the latest version of Cocos2d-X Extract it to your C:\ Drive I extracted mine at E:\cocos2d-x-2.2 Setup Environment Variables for Java, Cocos2d-x, SDK and NDK: Mine will look like below: COCOS2DX_ROOT E:\cocos2d-x-2.2 ANDROID_SDK_ROOT E:\adt-bundle-windows-x86_64-20130717\sdk NDK_ROOT E:\android-ndk-r9 JAVA_HOME C:\Java_32_Bit\jdk1.7.0_40\ If you are not sure how to set the environment variables here is a quick guide: http://www.computerhope.com/issues/ch000549.htm Open Cygwin: Right click on the icon and Run as administrator We want to create a new cocos2d-x project now We will create it for all the platforms and select only the android one later cd $COCOS2DX_ROOT cd tools/project-creator Now enter the below command to create a new project: python /create_project.py -project TestGame -package com.MyCompany.TestGame -language cpp A new project will be created under the projects directory For me it will be in the location E:\cocos2d-x-2.2\projects While running the create_project.py script, If you are seeing some error like: E:\cocos2d-x-2.2\tools\project-creator>create_project.py -project MyGame -package com.webfolks.AwesomeGame -language cpp File "E:\cocos2d-x-2.2\tools\project-creator\create_project.py", line 63 print "Invalid -project parameter" ^ SyntaxError: invalid syntax Perform the below steps to fix this issue: Put all the print statements in the create-project.py file in paranthesis Original statement: print "Usage: create_project.py-project PROJECT_NAME-package PACKAGE_NAME-language PROGRAMING_LANGUAGE" Revised statement: print ("Usage: create_project.py-project PROJECT_NAME-package PACKAGE_NAME-language PROGRAMING_LANGUAGE") Set Permissions: The problem with the generated new project is that, it is generated using a different user in windows and our actual login will not have access to copy or modify it For this to work, right click on the generated project folder ‘TestGame’ go to the Security Tab, click Advanced and select the first option Allow, Everyone, Full Control, This folder subfolders and files Screen shots below Also check the option ‘Replace all child object permission entries with inheritable permission entries from this object’ This will modify the permissions for all subfolders 10 Now we are done creating a project To import this to Android we need to build the generated project with NDK To this go to cygwin and navigate to the TestGame folder that we created Now go to the proj.android folder Here, we need to run the build_native.sh script Enter the command: / build_native.sh It will take a while for the build to complete Most of you might see an error like: cygwin warning: MS-DOS style path detected: E:\android-ndk-r9/ndk-build Preferred POSIX equivalent is: /cygdrive/e/android-ndk-r9/ndk-build One way to fix this is to go the environment variables and change the NDK_ROOT from E:\android-ndk-r9 to /cygdrive/e/android-ndk-r9/ndk-build If you this you need to restart cygwin and run the build_native.sh I prefer an alternate method where I will edit the build_natiive.sh file and set the NDK_ROOK temporarily In Windows, go to the newly created project folder ‘proj.android’ and then navigate to proj.android Here you will see a file called build_native.sh Open this file in any of the text editor and add the below line in the second line: set $NDK_ROOT = "/cygdrive/e/android-ndk-r9/ndk-build"; With this step there is no need to restart cygwin 11 Now, in cygwin go to the newly created project folder and go to the proj.android folder Now run the command : / build_native.sh It would take a while for your project to be built 12 Once this is done copy the entire project to any other location, I choose Desktop\Cocos_Games Open Eclipse(Remember, you dowloaded the ADT from Android site for SDK and Eclipse), and import the new project File > Import > Existing Android Code Into Workspace > Next In the Root Directory click on Browse and navigate till proj.android and click ok Note: Do not select ‘Import to Workspace’ Option 13 You will see some errors in the imported project saying that it certain cocos2d import statements failed to be imported To fix this follow the below steps(Thanks to Paras Mendiratta): 1: In Eclipse, right-click on your project and select the last option "properties" 2: In Project Properties window, select "Java Build Path" in the left pane 3: Under Java Build Path, select tab "source" It should be selected by default 4: Click on button "Link Source" 5: Browse it to following location-> COCOS2DX_INSTALLATION_FOLDER/cocos2dx/platform/android/java/src My path will be: E:\cocos2d-x2.2\cocos2dx\platform\android\java\src 6: Give any folder name For example, remove src and replace it with: Cocos2d-x-source Click Finish We are done now Run your poject on an Andorid Device and it should show you the nead cocos2d-x logo Please note that running this in an Android Virtual Machine may not always work ... "Link Source" 5: Browse it to following location-> COCOS2DX_ INSTALLATION_ FOLDER /cocos2dx/ platform/android/java/src My path will be: E:cocos2d-x2.2 cocos2dx platformandroidjavasrc 6: Give any... C:Java_32_Bitjdk1.7.0_40 If you are not sure how to set the environment variables here is a quick guide: http://www.computerhope.com/issues/ch000549.htm Open Cygwin: Right click on the icon and... cocos2d-x project now We will create it for all the platforms and select only the android one later cd $COCOS2DX_ ROOT cd tools/project-creator Now enter the below command to create a new project: python