Outdated Docs > How to set up the android cocos2d-x development environment on Windows 7

How to set up the Android Cocos2d-x development environment on Windows 7

Note: This tutorial is mainly for cocos2d-x 2.x version. Since cocos2d-x 3.x doesn’t need to install Cygwin for building android samples any more, you can refer to this post for more information.

Set up the Android Cocos2D-x development environment on Windows 7 is not difficult, but since the framework is updated frequently it looks like many users have problems with this. I hope you found this tutorial useful and enjoy coding.

ADVISE: In order to avoid security related problems, do all the actions with a user with administrator permissions, and when running commands, make sure to open the console as an administrator.

In this tutorial, I will show you how to set up cocos2d-x android development on windows 7. To follow this tutorial, you should have a PC with windows 7 installed and visual studio 2010 installed. It is better to have a very fast and stable network connection, because there are many software packages need to be downloaded during this tutorial.

Download cocos2d-x 2.2

NOTE: The current latest version cocos2d-x 2.2.

we can go to cocos2d-x offical website to download the latest stable version of cocos2d-x.

After your click the Download tab in the navigation bar, you will find a cocos2d-x download section like this:

From the above picture, we can see that there are two versions available, one is called cocos2d-x 2.2 and the other is called cocos2d-x 3.0 pre-alpha0.

In this tutorial, I will take cocos2d-x 2.2 as a example.

(Note: If you want to download any old version of cocos2d-x, you can go to the link named “looking for an old versoin?”. But I highly recommend you to try out the lastest version of cocos2d-x, it has many new features and bug fixes.).

Ok, right click the download link and choose “save link as…” to save the zip file to a proper location. In our case, the location is C:2d-x-2.2.0.

(Update: Don’t put cocos2d-x folder under c: since it will cause many privilege related problems. Try to put it in another disk, like D: E:etc.)

Unzip the package and the directory looks like this:

Getting Started with cocos2d-x

Do you see the red line in the above picture? Double click the file named cocos2d-win32.vs2010.sln, then it will launch your visual studio 2010.

Now you can make the HelloCpp project as the default startup project and press ctrl-F5 to run the sample. If you can build without any errors and run successfully. You will get the following results:

Congratulations! You have successfully made cocos2d-x running on your Win7. Now it’s time to configure the android development environment.

Configure android development environment

Since we are targeting Android development, so the first software package we need to install is definitely JDK. If you are running a 64 bit win7, you should download the responding 64 bit JDK for windows 64bit, the current latest version of JDK for window7 64bit is jdk-7u45-windows-x64.exe.

Once your have finished the download, you can install the JDK. After installation, you’d better to setup a environment variable named JAVA_HOME, in our case it is: C:Files\Java\jdk1.7.0_45

(Note: If you have any problems with environment variable setup, you can refer to this post for help.)

Now let’s download Android SDK . The Android SDK contains the following apps which are needed for developing your android apps.

  • Eclipse + ADT plugin
  • Android SDK Tools
  • Android Platform-tools
  • The latest Android platform
  • The latest Android system image for the emulator

It will take you several minutes to finish it, depending on your network bandwidth. After downoload, you can unzip it and put it on the followiwng director:C:-bundle-windows-x86_64. In the folder, there is a eclipse.exe file under C:-bundle-windows-x86_64\eclipse folder, I sent it to the desktop as a shortcut.

Now we can double click the shortcut on the desktop, then the eclipse will be launched along with a prompt dialog appeares. It asks us to set a default workspace. You can just choose OK to accept the deault settings.

Before importing the sample Android project, we need to setup a new environment variable named ANDROID_SDK which value is C:-bundle-windows-x86_64\sdk.
Next, we should install cygwin. My installation path is C:64\bin When you finish downloading, you should install the following software packages through cygwin:
<pre><code class="cpp">
autoconf, automake, binutils, gcc-core, gcc-g**, gcc4-core, gcc4-g**, gdb, pcre, pcre-devel, gawk, make
Now we should add cygwin’s bin folder at the end of the system’s PATH. I also added android platform tools at the end of the system’s PATH. Here is my PATH environment variable.
<pre><code class="cpp">
After you finish installing, you should install another software package named Android NDK. Here is the download link. When you finish downloading, unzip it and put it at C:-ndk-r9 and setup another environment variable named NDK_ROOT pointing at the url.

Finally, we can launch eclipse and import a sample android project within cocos2d-x folder. Here is the instructions:

  • Right click Package Explorer and choose “Import…”
  • When a dialog will appear , you should choose “Exsiting Android project into workspace”

  • Now you can choose import folder as C:2d-x-2.2.0\samples\Cpp\HelloCpp\proj.android. Now you will get the following result:

You may notice that there are some errors shown in the Package Explorer:

This is duing to the lack of cocos2d-x android jni bridge library. We can fix the problem by importing another android project. The location of the project is at C:2d-x-2.2.0\cocos2dx\platform\android. After you have imported the project, the errors will disappear.

Test Your Cocos2d-x Android NDK Environment

This time we will switch to use terminal, not windows’ CMD tool. Open the directory c:64, and double click the Cygwin.bat. Then a terminal will appear and you can use bash command to locate your cocos2d-x android project.

Here is my instruction:

cd /cygdrive/c/cocos2d-x-2.2.0/samples/Cpp/HelloCpp/proj.android/

Now you can run this command:


If there are no errors. Congratulations, your cocos2d-x android development environment on win7 is working.

(Note: you can also run your android applicaton through Eclipse. Right click the androd project and choose “Run as Android Application”.)

Install the apk on your android phone.

We can use the following command to install the HelloCpp.apk to our android phone.

adb install  bin/HelloCpp.apk

(Note: you should do some configurations if the above instruction is failed. Here is the solution)


  • The Android AndroidManifest.xml is missing error. Solution

  • Android requires compiler compliance level 5.0 or 6.0. Found ‘1.7’ instead. Solution.

  • Unable to add ‘C:2d-x-2.2.0\samples\Cpp\HelloCpp\proj.android\assets\fonts\Marker Felt.ttf’: Zip add failed. Solution. Similar problems are xxx.png files can’t be added. The solution is to change the access control of the file by using chmod command in cygwin environment.(Update: You can run your eclipse as Administrator, then the privilege problems will disappear.)

  • Sometimes the errors are really weird, I suggest you to disable “Build automatically” option, clean all projects and rebuild the workspace. Even sometimes you need to restart your eclipse and do the same process again and again. Android NDK development on windows platform is really shit[]()

  • If your eclipse is not working, you could try out using command line tools. Here I will show you one solution. At first, you should add ‘ant’ build command at the end of your PATH environment variable. The value is :C:-bundle-windows-x86_64\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\bin. Then, you can refer to this post to build and install apk to your android phone.

  • Android dependency error:

The solution is opening your project’s “Build path…” => “Configure build path”, then select Library tab and remove the error library dependency.

If you have any kinds of problems during the configuration process, please let me know and I’ll try my best to answer these questions and update this tutorial.

getcocos2d-x.jpeg (62.6 kB) owen, 2013-10-28 08:14

hellocpp.jpeg (41.2 kB) owen, 2013-10-28 08:18

cocos2dxversion.jpeg (24 kB) owen, 2013-10-28 08:19

cocos2dxdirectory.jpeg (61.1 kB) owen, 2013-10-28 08:20

importandroid.jpg (45.9 kB) owen, 2013-10-28 08:38

buildsample.jpg (192.9 kB) owen, 2013-10-28 08:41

cocos2dandroiderror.jpg (38.1 kB) owen, 2013-10-28 08:42

cocos2dxandroidsuccess.jpg (40.8 kB) owen, 2013-10-28 08:45

androiddependency.jpg (93.4 kB) owen, 2013-10-28 08:55

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.