My environment is ubuntu 12.04, android-ndk-r8, Cocos2d-2.0-x-2.0.4, eclipse 3.7.2
I have set up the NDK development environment before. For the NDK environment, see Android NDK development and configuration NDK.
1. Configure NDK and SDK
Enter the Cocos2d-2.0-x-2.0.4, open the create-android-project.sh with gedit, make the following changes
[Cpp] view plaincopyprint? NDK_ROOT_LOCAL = "/home/zhycheng/android-ndk-r8"
ANDROID_SDK_ROOT_LOCAL = "/home/zhycheng/android-sdk-linux"
NDK_ROOT_LOCAL = "/home/zhycheng/android-ndk-r8"
ANDROID_SDK_ROOT_LOCAL = "/home/zhycheng/android-sdk-linux" specifies the NDK and SDK directories.
Then run the file to generate the andriod project.
2. Compile
Open the. bashrc file and add
Export NDK_ROOT =/home/zhycheng/android-ndk-r8
Go to the android project and run build_native.sh.
[Cpp]
Zhycheng @ zhycheng-Lenovo-B460 :~ /Cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android $./build_native.sh
Zhycheng @ zhycheng-Lenovo-B460 :~ /Cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android $./build_native.sh
The following result is displayed:
[Cpp] view plaincopyprint? NDK_ROOT =/home/zhycheng/android-ndk-r8
COCOS2DX_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android /../..
APP_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android /..
APP_ANDROID_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android
Using prebuilt externals
Make: Entering directory '/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android'
Gdbserver: [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup: libs/armeabi/gdb. setup
Install: libgame. so => libs/armeabi/libgame. so
Make: Leaving directory '/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android' www.2cto.com
Zhycheng @ zhycheng-Lenovo-B460 :~ /Cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android $
NDK_ROOT =/home/zhycheng/android-ndk-r8
COCOS2DX_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android /../..
APP_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android /..
APP_ANDROID_ROOT =/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android
Using prebuilt externals
Make: Entering directory '/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android'
Gdbserver: [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup: libs/armeabi/gdb. setup
Install: libgame. so => libs/armeabi/libgame. so
Make: Leaving directory '/home/zhycheng/cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android'
Zhycheng @ zhycheng-Lenovo-B460 :~ /Cocos2d-2.0-x-2.0.4/cocos2d-2.0-x-2.0.4/CocosGame/proj. android $
I have compiled it before. It takes some time to compile it. Finally, libgame. so is generated in the libs/armeabi folder.
3. Run
Import the project to eclipse, copy the org folder under the Coco2d-2.0-x-2.0.4 directory cocos2dx/platform/android/java/src to the android project src directory and start running. Note: you must use a real machine for testing. I encountered an error in testing on the simulator.
Finally, paste an image.
There are only 48 frames, much lower than on a pc.