Click New button to add a Path Variable COCOS2DX pointing to the root cocos2d-x directory.
C/C++ Environment Variable NDK_ROOT:
Eclipse->Preferences->C/C++->Build->Environment.
Click Add button and add a new variable NDK_ROOT pointing to the root NDK directory.
Only for Windows: Add new variables CYGWIN with value nodosfilewarning and SHELLOPTS with value igncr
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.
Adding and running from Eclipse
File->New->Project->Android Project From Existing Code
Browse to your project directory. eg: cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj.android/
Add the project
Click Run or Debug to compile C++ followed by Java and to run on connected device or emulator.
Running project from Command Line$ cd cocos2d-x/samples/Cpp/TestCpp/proj.android/$ export NDK_ROOT=/path/to/ndk$ ./build_native.sh$ ant debug install
If the last command results in sdk.dir missing error then do:
$ 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)