Mac configuration Android ndk environment and build a Cocos2d-x environment and eclipse normal compilation run cocos2dx comes testsdemo project!

Source: Internet
Author: User

Everyone knows that Cocos2d-X is a multi-platform support of the game engine, so today's most mainstream mobile phone system is iOS and Android, so indispensable Android kids shoes and IoS are biased towards the Cocos2d-X engine, and more Android Developers are still used to the IDE using eclipse, now the Cocos2d-X configuration in the eclipse environment of the tutorial is very few, so himi today to share their Mac OS to build an eclipse Android-Cocos2dx environment for your reference and exchange!

1. The first preparation work is to build an eclipse Android environment under MAC, because eclipse has a Mac version, and Android SDK ADT
Also have Mac version, it is easy to set up, all here will not go into details, but this step is required to do, but also below we configure the necessary conditions of Cocos2d-X Oh;

Himi eclipse version: Eclipse IDE for Java EE developers version: 3.7.0 (I downloaded it a long time ago)
Eclipse for Mac: http://eclipse.org/downloads/
Android SDK himi download version is android-sdk-mac_x86
Android SDK for Mac: http://developer.android.com/sdk/index.html
The himi ADT has been installed very early. You can install the latest one;

2. Normal in eclipse after building a good Android environment, we began to build a Cocos2d-X in xcode environment, this step if you have completed can skip this step, there is no children's shoes please move: [iOS-cocos2d-X
Game Development one] in the Mac combined with xcode to build a Cocos2d-X Development Environment & uninstall cocos2dx Template

3. After completing the above two steps, we download the necessary ndk (we all know that the underlying Cocos2d-X is C ++),: http://developer.android.com/sdk/ndk/index.html,
Himi download ndk version: Mac OS X (Intel) android-ndk-r7b-darwin-x86.tar.bz2

Download the ndk and decompress it;

4. After completing the first three steps, check whether JDK and ant on Mac are normal:
Open the terminal and enter Java-version and press Enter.
Enter ant-version and press Enter.
As follows:


Ant is recommended to use 1.8.0 or an updated version.

 

5. Now we start to configure relevant paths such as Cocos2d-X and compilation;

Here we will first introduce some himi folder paths for your reference:
Path to the Cocos2d-X:/users/himi/Documents ents/cocos2d-1.0.1-x-0.12.0
Android SDK path:/users/himi/documents/himiwork/androidtools/android-sdk-mac_x86
Android ndk path:/users/himi/documents/himiwork/androidtools/android-ndk-r7b

OK. Next we will start to configure the path. First Open "terminal" and then enter Pico. bash_profile and press Enter.

Then manually enter the following path:

export ANDROID_SDK_ROOT=/Users/Himi/Documents/HimiWork/AndroidTools/android-sdk-mac_x86/export ANDROID_NDK_ROOT=/Users/Himi/Documents/HimiWork/AndroidTools/android-ndk-r7bexport COCOS2DX_ROOT=/Users/Himi/Documents/cocos2d-1.0.1-x-0.12.0export NDK_ROOT=/Users/Himi/Documents/HimiWork/AndroidTools/android-ndk-r7bexport PATH=$PATH:$ANDROID_SDK_ROOTexport PATH=$PATH:$ANDROID_NDK_ROOT


As for the path, you can adjust it according to your own file path. The above himi file paths have been listed in detail. You can configure them accordingly!

Note that the path should not contain spaces!

After the input is complete, control + X is saved, and then the system prompts whether to save it. Enter y and press Enter!

OK. After configuring the path, we can monitor it!

Test path step: Close your terminal and re-open it. If there is a problem with the previous path configuration, the following prompt will appear when you re-open the terminal:-Bash: exoort: command not found. If no such prompt is displayed, "OK" indicates that the path configuration is complete!

 

6. Next I will try to compile the demo of cocos2dx and then himi IN THE NEXT blog will introduce to students how to create a new android-Cocos2dX project import eclipse run!

Open the terminal and enter CD $ cocos2dx_root and press Enter;
Then enter CD tests/enter;
Then enter CD test. Android/enter;
Enter./build_native.sh and press Enter;

If an error occurs, do not worry. The subsequent himi will be explained in detail. First, the normal situation will be compiled, for example:


If the following error message is prompted for the last compilation command:

"Eroor: cannot find 'make' program. Please install cygwin make package or
Define the gnumake variable to point to it ."

Solution:

1. download the following file:
Unzip make.zip ": http://vdisk.weibo.com/s/hq1VK
After the download is complete, decompress the package and you will see two files: Make gnumake

2. Right-click your finder and choose/usr/bin from the shortcut menu.
Then, move the two folders in. OK!

3. re-open the terminal and enter the following commands in sequence:
CD/usr/bin press ENTER;
Chmod 777 make press ENTER;
Make-version press ENTER;
Check whether your make is normal:
Enter the command: which make and press enter on the terminal;
Normally, the make path is displayed! Solve the problem! Try compiling again in the previous order!
Here thanks to the Cocos2dX-1 group of friends to provide the solution! (Himi is also not compiled here)

After the compilation is successful, open eclipse, select Create project from existing source> new Android project>, select tests/test. Android in the cocos2dx path, and finish the import:


OK, project-clean under the project, and then we run. Here, himi fails to run with the simulator, but the real machine runs well, as shown below:

OK, this article is here first, the next article details how to create a cocos2dx-android project and run the simulator and real machine in eclipse!

Post: http://www.himigame.com/android-game/636.html

Related Article

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.