ubuntu12.10 COCOS2DX 2.2.1 Project transplanted to Android

Source: Internet
Author: User

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.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.