build an Android project on Cocos2d-x 3.0-eclipse
April 30, 2014 at the end of April
This article continues to introduce some of the basics of Cocos2d-x 3.0, and the previous blog describes how to compile our Cocos2d-x project on Visual Studio 2012 and successfully run the HelloWorld. It's similar to the previous version, except that when you create an empty project, the command becomes Cocos. What this blog brings to you is how to run our Cocos2d-x project in Eclipse, if the children's shoes have to look at my writing Cocos2d-x 2.2.3 version of the cross-compilation environment, after reading this blog, you will know Cocos2d-x 3.0 unexpectedly changed so much, it became so simple, the configuration of trouble is gone, reducing the difficulty of learning.
Required Environment
- Download ADT Bundle (Eclipse bundled SDK and ADT) http://developer.android.com/sdk/index.html
- Install the JDK, NDK, Python, and then configure the environment
Work Flow
When we use Eclipse to build Android, we recommend that you follow these steps:
- Go to the COCOS2DX project you created, go to the proj.android directory, like the wizard created a project called Mygame under e:/myproject/, and go to the Mygame/proj.android directory and execute the following command:
python build_native.py(Note: If you want to run the Cpp-tests project provided by Cocos2d-x, go directly to the build directory and run the command Python android-build.py-p cpp-tests)
After compiling, we can import the Proj.android project into our eclipse.
- Then use Eclipse to open an existing Android project
- Import the LIBCOCOS2DX project (note: Do not import the Java project directly under the D:\Cocos2dx\cocos2d-x-3.0\cocos\2d\platform\android directory unless you are creating a cpp-tests project, This is the test project provided by Cocos2d-x, if you use the Cocos command to create a project, make sure LIBCOCOS2DX is in the directory where your project is located, such as the Java project under MyProject is copied from the COCOCS2DX. Put it in a directory with the project that we created with the Cocos command, and then import it with Eclipse. As shown in the following:
- You can then right-click->run as to run the Android project directly without additional configuration (Cocos2d-x 3.0 is simple).