- Android NDK
- Android SDK OR Eclipse ADT Bundle
- Android AVD target installed
There are two ways of building Android projects.
- Eclipse
- Command Line
- Complete workflow from Eclipse, including: a. Build C++. b. Clean C++. c. Build and Run whole project. d. Logcat view. e. Debug Java code. f. Javascript editor. g. Project management.
- True C++ editing, including: a. Code completion. b. Jump to definition. c. Refactoring tools etc. d. Quick open C++ files.
NOTE: This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. Skip this section if you've done this before.
-
Download Eclipse ADT bundle from Google
OR
Install Eclipse with Java. Add ADT and CDT plugins.
-
Set up Variables:
-
Path Variable COCOS2DX: A. Eclipse->Preferences->General->Workspace->Linked Resources B. Click New button to add a Path Variable COCOS2DX pointing to the root cocos2d-x directory (Directory containing cocos2dx/ external/ tools/ scripting/ etc.).
-
C/C++ Environment Variable NDK_ROOT: A. Eclipse->Preferences->General->C/C++->Build->Environment. B. Click Add button and add a new variable NDK_ROOT pointing to the root NDK directory.
-
-
Import libcocos2dx library project:
- File->new->Project..->Android Project From Existing Code.
- Click Browse button and open cocos2d-x/cocos2dx/platform/android/java directory.
- Click Finish to add project.
- File->new->Project..->Android Project From Existing Code
- Browse to cocos2d-x/cocos2dx/projects/Name Of Project/proj.android/ directory.
- Add the project
- Click Run or Debug to compile C++ followed by Java and to run on connected device or emulator.
cd cocos2d-x/projects/Name Of Project/proj.android/
export NDK_ROOT=/path/to/ndk
./build_native.sh
ant debug install
- If step 4 results in sdk.dir missing error then follow step 6-8.
android list target
android update project -p . -t (id from step 6)
android update project -p cocos2d-x/cocos2dx/platform/android/java/ -t (id from step 6)