Developers Manual > Cocos2d-x > Getting Started with Cocos2d-x > How to Build an Android Project with Eclipse

How to Build an Android Project with Eclipse

Environment Requirements

We will be using OS X in this example. The process on Win32 and Linux is more or less the same.


Once completed:

Open the project with Eclipse.

  • Launch Eclipse

  • Right click your mouse at the empty area of the Package Explorer and choose Import....

  • Choose Existing Android Code Into Workspace from the pop up dialog and Click Next.


  • Click the Browse... button to choose the directory of Cpp-Tests' and Click Ok.

Before choosing the directory:

After choosing the directory:

  • Click Finish.

If all the above processes are correct, the Finish button will be enabled and you should click it.


Import Libcocos2dx Project

This is more or less the same process as we do in the previous section except for the path of the is different.

The path of the libcocos2dx project is [your own game project folder]/cocos/2d/platform/android/java.

(Note:Here you must select the project right under your own project!!)

Build and Run the Android Project

  • Connect your Android phone with USB remote debugging option enabled.

  • Make sure your computer can recognize your phone (you might need to install drivers for your specific phone)

  • Right Click The CppTests project and choose Run as... -> Android Application.


Build an Empty Project Created with the cocos command

Build it with the cocos command

(Note this might not be the same as the previous section, but you can do it by navigating to the directory and run the scripts.)

We could use cocos run -s ~/MyCompany/MyGame -p android command instead of the python scripts. You could refer to this document for more information.

Open the project with Eclipse

It's exactly as the process we do in the previous example, above.

Import the Libcocos2dx Project

It's exactly as the process we do in the previous example, above.

Build and Run the Android Project

It's exactly as the process we do in the previous example, above.


  • If you get errors in the Eclipse when you imported the Android project. Don't worry, just import the libcocos2dx project will get ride of it.

  • If you imported all the projects and the errors remains, you might need to build the libcocos2dx project manually and to see whether there is a libcocos2dx.jar file under the bin directory.

  • If you installed the project in your Android phone but it crashed when launching. You should make sure there is a file under the libs/armeabi directory.

image6.png (206.6 kB) owen, 2014-04-02 06:12

image1.png (11.7 kB) owen, 2014-04-02 06:12

image2.png (63.2 kB) owen, 2014-04-02 06:12

image3.png (240.9 kB) owen, 2014-04-02 06:12

image4.png (275.1 kB) owen, 2014-04-02 06:12

image5.png (153.9 kB) owen, 2014-04-02 06:12

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