Cocos2dx:Android
lastmod 2018-08-17created 2017-11-103 edits
Notes on how to start an Android project using Cocos2dx.
Environment variables
First, the following environment variables need to be set.
-
COCOS2DX_ROOT: Cocos2dx root directory. -
CYGWIN: Cygwin ROOT directory. (The directory containing the Cygwin.bat file) -
ANDROID_SDK:Android SDK ROOT directory. -
ANDROID_NDK: Android NDK ROOT directory.
Integrating Cocos2dx with Eclipse and ADT
- After installing the SDK, create a project using the create-android-project.bat file.
- The Classes, proj.android, and Resources directories are created.
- Copy all files in Classes to proj.android/jni. After copying, edit the proj.android/jni/Android.mk file accordingly.
- Copy all files in Resources to proj.android/assets.
- Edit the contents of Project > Properties > C/C++ Build > Builder Settings > Build command:.
- ndk-build "NDK_MODULE_PATH=COCOS2DX_ROOT;COCOS2DX_ROOT/cocos2dx;COCOS2DX_ROOT/cocos2dx/platform/third_party/android/prebuilt"
The directories required for this project are listed below.
-
COCOS2DX_ROOT/cocos2dx -
COCOS2DX_ROOT/CocosDenshion -
COCOS2DX_ROOT/extensions -
COCOS2DX_ROOT/external
Troubleshooting
Unknown host operating system
On Windows, the following error message may appear.
In this case, change the Build command from ndk-build ... to ndk-build.cmd ....
See also
Favorite site
- [Recommended] Setting up a cocos2d-x Android development environment 1
- cocos2d-x Android Window setting (0) setting preparation
References
-
Create_android_cocos2dx_project.pdf ↩
Pages that link here