Original article, reproduced please indicate everywhere: http://blog.csdn.net/zhy_cheng/article/details/8276848
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
NDK_ROOT_LOCAL="/home/zhycheng/android-ndk-r8"ANDROID_SDK_ROOT_LOCAL="/home/zhycheng/android-sdk-linux"
Specifies the directory of the ndk and SDK.
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.
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:
NDK_ROOT = /home/zhycheng/android-ndk-r8COCOS2DX_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.androidUsing prebuilt externalsmake: 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/gdbserverGdbsetup : libs/armeabi/gdb.setupInstall : libgame.so => libs/armeabi/libgame.somake: 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.