Android cocos2d-x Development (3): Creating Android project and compiling

Source: Internet
Author: User

1. Go to the cocs2d-x directory and open the create-android-project.bat with a text editor

Set _ cygbin = to the absolute path of cycgwin \ bin installation.

Set _ androidtools to the absolute path of Android SDK tools

Set _ ndkroot to the absolute path of Android ndk.

Modified and saved

Double-click the create-android-project.bat to start the project creation wizard

First, enter the package name (we recommend that you follow the naming rules of Android), such as com. Android. Test.

Enter the project name (do not enter the name of the existing folder. If the name is the same, it will be overwritten), such as testandroid

2. ndk source code compilation
A, enter the cocos2d-x \ testandroid \ Android directory, right-click to open build_native.sh, You need to modify android_ndk_root for your specific ndk path
Android_ndk_root =/cygdrive/e/android-ndk-r5
Cocos2dx_root =/cygdrive/D/work7/cocos2d-x
Game_root = $ cocos2dx_root/testandroid
Game_android_root = $ game_root/android

Resource_root = $ game_root/Resource

Versions 2.0.3 should be:

Add the path to your ndk, for example:

Ndk_root = "/cygdrive/E // Android/android-ndk-r8b /"

Modify the following path, for example:

Cocos2dx_root = "/cygdrive/e/Android/cocos2d-2.0-x-2.0.3 /"
App_root = "/cygdrive/e/Android/cocos2d-2.0-x-2.0.3/cocos2dx2 /"
App_android_root = "/cygdrive/e/Android/cocos2d-2.0-x-2.0.3/cocos2dx2/proj. Android /"

B. Open cygwin, enter the testandroid/Android directory, and enter./build_native.sh to start compiling.

In version 2.0.3, it should be the proj. Android directory.

C. After the compilation is successful, the so file (libgame. So) will be generated directly under the directory testandroid \ Android \ libs \ armeabi)
3. Run the new project
Open eclipse, select File-> New-> Android project, and then select Create project from existing source
Select the \ cocos2d-x \ testandroid \ Android directory. The project is successfully created from the file (the corresponding APK package will be generated in the \ testandroid \ Android \ bin directory)

Run the project, right-click the project, and choose run as> Android Application

In version 2.0.3, add the org. cocos2dx. Lib project to eclipse. The path is as follows:

E: \ Android \ cocos2d-2.0-x-2.0.3 \ cocos2dx \ platform \ Android \ Java \


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.