1. To the Proj.android directory of the project file, edit the build_native.sh file to specify the NDK and COCOS2DX paths
Export Ndk_root=/home/liyuchen/dev/android-ndk-r9dexport NDK_MODULE_PATH=/HOME/LIYUCHEN/DEV/COCOS2D-X-2.2.1/ Cocos2dx
2. Execute the Script
./build_native.sh
The error here is more related to the NDK version
3. Existing Android Code into Workspace in Eclipse (already configured with Android SDK and NDK) import,android
Usually arrive at this step will be error, if the source file is missing, please go to the COCOS2D-X-2.2.1/COCOS2DX/PLATFORM/ANDROID/JAVA/SRC directory to import all the files into the Eclipse project under the SRC
4. Modify the Jni/android.mk file
If the new project does not need to be modified, skip this step. If an existing project is to be ported to Android, add the new source file to the Android.mk file, which is similar to the makefile file, such as a new MainScene.cpp in the classes directory, you need to make the following changes (red part is modified)
Local_path: = $ (call My-dir) include $ (clear_vars) Local_module: = Cocos2dcpp_sharedlocal_module_filename: = Libcocos2dcpplocal_src_files: = Hellocpp/main.cpp. /.. /classes/appdelegate.cpp. /.. /classes/helloworldscene.cpp.. /.. /classes/mainscene.cppLocal_c_includes: = $ (Local_path)/. /.. /classeslocal_whole_static_libraries + = cocos2dx_staticlocal_whole_static_libraries + cocosdenshion_staticLOCAL_ Whole_static_libraries + = box2d_staticlocal_whole_static_libraries + chipmunk_staticlocal_whole_static_libraries + = Cocos_extension_staticinclude $ (build_shared_library) $ (call IMPORT-MODULE,COCOS2DX) $ (Call IMPORT-MODULE,COCOS2DX /platform/third_party/android/prebuilt/libcurl) $ (call Import-module,cocosdenshion/android) $ (call Import-module, Extensions) $ (call import-module,external/box2d) $ (call Import-module,external/chipmunk)
5. Modify the Androidmanifest file, change the horizontal screen to vertical screen, this step can be ignored, depending on the situation.
android:screenorientation= "Landscape" modified to android:screenorientation= "Portrait"
If the android.mk file in the run-time JNI directory is an error, this file is more cumbersome to modify
Mostly related to the NDK version, I replaced the ndk9d version after the problem solved
6.Run as Android application, an APK file will be generated in the bin directory of the Proj.android, and this is the end of the migration.