Build an Eclipse compiling environment for cocos2d-x-2.2

Source: Internet
Author: User

A few days of painstaking efforts have been made, and various errors and methods have finally been settled.

Cocos2d-x-2.2 is a relatively stable version, cocos2d-x versions are somewhat different, so it is not guaranteed to be the same! The following is my summary on the XP system.

I suppose: before reading the following content, you have installed the necessary tools for Android development in the Eclipse environment. (if not, download the toolkit on the google website, at present, google has all the tools are packaged, you only need to download and decompress to use, of course, jdk needs to install their own), Official Website: http://developer.android.com/tools/sdk/ndk/index.html

First need to download android-ndk provided by google, go to the official website to download, the latest version of android-ndk-r9, download this latest on it. Compared with earlier versions, the new NDK version can be compiled without installing a Linux virtual machine, that is, you do not have to install Cygwin. Download and decompress the package.

Decompress the cocos2d-x-2.2.zip file on the official website. Cocos2d-x-2.2 official website is recommended Python tool to create a project, the current version of Python27 download and install it can be used (Note: Python High Version of the problem, remember to use Python27 version ), cocos2d-x-2.2 \ tools \ project-creator directory create_project.py this file contains specific instructions for creating projects, you can create NewProject in this directory. bat this batch file, so that you can easily create a project, when the creation is successful, it will generate a project directory in the cocos2d-x-2.2 directory its project is here.

Next, Eclipse to import the cocos2d-x-2.2 project steps:

1:

Eclipse: Import select Existing Android Code Into Workspace to Import the project that exists in the cocos2d-x-2.2.

G: cocos2d-x_DEVELOP \ cocos2d-x-2.2 \ samples \ Cpp \ SimpleGame \ proj. android

Note: Copy projects into workplace cannot be selected here, otherwise various problems may occur.

2:

Add the following code (red) in this file: cocos2d-x-2.2 \ samples \ Cpp \ SimpleGame \ proj. android \ jni \ Android. mk

$ (Call import-add-path, G:/cocos2d-x_DEVELOP/cocos2d-x-2.2)
$ (Call import-add-path, G:/cocos2d-x_DEVELOP/cocos2d-x-2.2/cocos2dx/platform/third_party/android/prebuilt)

Include $ (BUILD_SHARED_LIBRARY)

Add the following code (red) in this file: cocos2d-x-2.2 \ samples \ Cpp \ SimpleGame \ proj. android \ jni \ Application. mk

NDK_MODULE_PATH: = G:/cocos2d-x_DEVELOP/cocos2d-x-2.2/cocos2dx/platform/third_party/android/prebuilt

3:

Eclipse-> Window-> Preferences-> Android-> NDK add NDK Location (as shown below ):

G: \ cocos2d-x_DEVELOP \ android-ndk-r9c

4:

Configure a Builders for the cocos2d-x project imported by Eclipse:

Eclipse-> Package Explorer-> select project and click, select Properties-> Builders and click new on the right, and then select Program-> OK to create a new Builders

Install the following flowchart for configuration (the company's computer cannot be encrypted, so you can only use your mobile phone to take photos ):

Note: The project name I imported from Eclipse is My_first_example.

First open: Properties (for example)

Select Builders-on the left and click new on the right to create a new Builder (for example ):

Select: Program (for example)

Choose main> give a name (here I am: New_Builder ), <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + bM7tC0yc + weight + Weight = "http://www.2cto.com/uploadfile/Collfiles/20140311/20140311085633194.jpg" alt = "\">

Choose Environment> New to create a New Environment variable:

NDK_MODULE_PATH

G: \ cocos2d-x_DEVELOP \ cocos2d-x-2.2 \ cocos2dx \ platform \ third_party \ android \ prebuilt; G: \ cocos2d-x_DEVELOP \ cocos2d-x-2.2

Set automatic compilation when refreshing the project. Select Refresh-> Configure as follows:

You also need to configure Build Options (as shown below)

Finally, click OK to configure the new Builder.

Finally, you need to configure one. Select C/C ++ Build on the left. Configure the Build command Information (for example)

G: \ cocos2d-x_DEVELOP \ android-ndk-r9c \ ndk-build.cmd

In this way, NDK can be compiled normally during Eclipse compilation.


Through the configuration in the above four steps, your project can be compiled normally, but it still cannot be run successfully, and various errors are reported. So there are two steps:

First, copy the files in G: \ cocos2d-x_DEVELOP \ cocos2d-x-2.2 \ cocos2dx \ platform \ android \ java \ src \ org to your android project,

Here I copy the org folder together to the My_first_example \ proj. android \ src directory of my project.

In this way, your project will be fully compiled in Eclipse and can be run. However, the following error will be reported:

03-10 07:05:47. 931: D/cocos2d-x debug info (1116): Get data from file(CloseNormal.png) failed!
03-10 07:05:47. 931: D/cocos2d-x debug info (1116): Get data from file(CloseSelected.png) failed!
03-10 07:05:48. 223: D/cocos2d-x debug info (1116): Get data from file(HelloWorld.png) failed!
03-10 07:05:48. 223: A/libc (1116): Fatal signal 11 (SIGSEGV) at 0x00000000 (code = 1), thread 1129 (Thread-108)

The error message indicates that many image resources cannot be found.

The last step is to copy all the Resources of the cocos2d-x Project (all the content in Resources) to the proj. android \ assets Directory.





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.