Cocos2dx series notes (2)-Subsequent Android environment configuration in windows, cocos2dxandroid

Source: Internet
Author: User

Cocos2dx series notes (2)-Subsequent Android environment configuration in windows, cocos2dxandroid

Part 1

For those who want to use cocos2dx to develop Android games, the most painful problem is the configuration of the Android environment and the strange compilation failure. This is an experience package of blood and tears after many successes and failures. please collect it. If you have more convenient methods, please be sure to advise me. Thank you!

Because of the Great Wall of China, you need some external help, such as VPN, or the website AndroidDevTools, to build the android environment. It contains the vast majority of android development needs.

For how to build the android environment, due to the tight schedule, I will not illustrate the text. In this article, I will briefly describe the following five parts:

1. Java environment Configuration

Prepare the basic software: JDK. You can go to the official website to get the latest software, and then set the Java environment variable.

2. ADT Configuration

Android development artifacts are Eclipse + ADT. Eclipse goes to the latest version on the official website, ADT goes to the latest version of AndroidDevTools, and sets ADT according to instructions in AndroidDevTools.

If you do not want to take this step, please add the ADT Bundle, which includes Eclipse, ADT plug-ins, and SDK Tools. It is an integrated IDE. You only need to install Jdk to start development, we recommend that you download the ADT Bundle for beginners.

3. SDK Configuration

You must have an SDK for android development. Go to AndroidDevTools and follow the instructions to download the package, decompress the package, and configure the SDK environment variables. You do not have to install the SDK through SDK Manager.

To put it simply, pay attention to the following:

Set environment variables:

 

4. NDK Configuration

Because I plan to use C ++ for development on the cocos2dx platform, I must configure the NDK

C/C ++: Android Application toolkit,In Linux/Mac OS X, the NDK r10c can also be downloaded from AndroidDevTools.

In the end, it is very important to configure environment variables.

 

5. cocos2dx Android compiling environment

Android compilation environment requires the use of Andorid_SDK \ Android_NDK \ Ant and JDK. Here, only ANT is available, so please go to the ANT official website to download the latest: ANT

After finally completing all the necessary preparations, the key step is displayed immediately:

First, we recommend that you change the SDK \ NDK \ ANT path to a short name such as SDK \ NDK \ ANT (in fact, I changed it from the very beginning. If there is a problem with the variable, remember to modify the table and hit me. Hurry and escape.

This is to facilitate future use.

After finishing the configuration, we start to continue the Configuration:

 

  • After the manual Association is completed, we recommend that you run setup. py in the cocos2dx file to complete the association of other cocos (blood and tears, not crying here)
  • Run setup. py again to check whether all the configurations are correct. The following figure is displayed. Otherwise, check the environment variables.
  • It is often reported that the cocos command cannot be played out, so in the Path variable, add C: \ cocos2dx; (your cocos2dx directory Path)
  • Then we can use cocos compile-p android -- ap 18 to compile the APK file in the project directory. For specific compilation commands, see CMD help.
  • 6. Private compilation experience

    Of course, this will basically end. In the spirit of conscience, we will continue to reveal the pitfalls we will encounter later.

    1. We recommend that you copy com and org under cocos2dx \ cocos \ platform \ android \ java \ src to the \ proj. android \ src path of your new project, and then compile it.

    For example, my project path is C: \ cocosDemo \ My2048Game \ proj. android \ src, cocos2dx adnroid src path C: \ cocos2dx \ cocos \ platform \ android \ java \ src

    Copy the src package of cocos2dx to the src project. Otherwise, the GEN folder cannot be generated during compilation ~

     

    2. Through step 1, you can avoid the error that the GEN file does not exist when eclipse opens the project android folder.

    3. Of course, adding the src Folder does not necessarily prevent the absence of GEN files, because you need to use the cocos compile-p android command to compile the files first.

    4. Summary of experience:

    Above

    ZhaoLion

    14:18:09

     

    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.