COCOS2DX Series notes (2)-Windows environment Configuration subsequent Android environment configuration

Source: Internet
Author: User
Tags android sdk manager android games

Continuation of the article

For those who want to use COCOS2DX to develop Android games, the most painful thing is to configure the Android environment and after the bizarre compilation failures. This is experienced after many successes and failures, blood and tears of the experience pack, please accept the good. If you have a more convenient way, please be sure to teach me, thank you!

Android environment because of the Great Wall of China, you need some outside help, like a VPN or this website: androiddevtools, which contains most of the things Android needs to develop.

For the Android environment how to build, due to the time is tight, I will not be illustrated, this article I would like to briefly describe the following 5 parts:

    1. Java Environment Configuration
    2. ADT Configuration
    3. SDK Configuration
    4. NDK Configuration
    5. COCOS2DX Android Compilation Environment
    6. Personal compilation Experience
1.Java Environment Configuration

Prepare the basic software: JDK, this you go to the official website of the latest on the line, and then set the Java environment variables.

    1. Click to add the following environment variable to the system variable, properties----environment variable---
    2. Java_home: C:\Program files\java\jdk1.8.0_25 (the file path of your JDK)
    3. Classpath for:.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar;%java_home%\bin; (Be careful not to miss the first ".", leaking the configuration fails)
    4. The path variable is added:%java_home%\bin; (set to the front of the variable value as far as possible)
    5. Check the JDK, open the cmd window, enter java–version to view the JDK version information. If the Java version that appears in CMD is the same as the one you configured, congratulations, the configuration is successful, or you can follow the above steps to check
2.ADT Configuration

Android development artifact is Eclipse+adt. Eclipse to the official website next to the latest version, ADT to Androiddevtools next the latest version, according to Androiddevtools inside the description set ADT.

For those who do not want to toss this link, please under the ADT Bundle, including the eclipse, ADT plug-ins and SDK Tools, is already integrated IDE, just install the JDK can begin to develop, recommend beginners download ADT Bundle, no need to toss the development environment.

3.SDK Configuration

Android Development must have the SDK, you go to androiddevtools inside, follow the instructions, download the package, unzip directly, and then configure the SDK environment variables can be used, do not have to go through the SDK Manager to install.

Simply note the installation of the bread:

  1. SDK: SDK for Android development, download and unzip, copy or move the entire extracted folder to a your sdk 路径/platforms folder, then open the SDK Manager, open the Tools(工具) menu selection Options(选项) menu item to open the Android SDK Manager Setting the dialog box, click Clear Cache(清除缓存) the button, and then restart Eclipse (or Android Studio) and SDK Manager.
  2. Build Tools: Android development required for the Build-tools, download and unzip, the extracted entire folder copied or moved to the your sdk 路径/build-tools folder.
  3. SDK Platform-tools: is the ADB, FastBoot and other toolkit. The extracted platform-tools folder is placed in the root directory of the Android SDK, and the adb directory is added to the system PATH path, you can directly access the command line ADB, FastBoot and other tools.
  4. Support Library: contains supportive, V7, and V13, download the extracted entire folder to copy or move to the your sdk 路径/extras next, then open the SDK Manager, open the Tools(工具) menu selection Options(选项) menu item Open the Android SDK Manager Setting dialog, click Clear Cache(清除缓存) the button, then restart Eclipse (or Android Studio) and SDK Manager.
  5. SDK System Image: This is the system image that is required when creating the emulator, that is, when the emulator is created, the CPU/ABI item needs to be selected, downloaded and unzipped, the entire extracted folder can be copied or moved to a your sdk 路径/system-images folder, if not system-imagesThe directory creates this folder first, then opens the SDK manager, opens the Tools(工具) menu selection Options(选项) menu item, opens the Android SDK Manager setting dialog, clicks the Clear Cache(清除缓存) button, and then restarts Eclipse ( or Android Studio) and SDK Manager.
  6. Android SDK Extras: Include,,,,,,,, and Android Support Library Google Cloud Messaging for Android Library Google Play services Google Play services for fit preview Google Play services for Froyo Google Play APK Expansion Library Google Play Billing Library Google Play Licensing Library so on, download the extract after the entire folder copied or moved to the your sdk root directory, If the folder already exists extras , replace it.

Set Environment variables:

    1. Click to add the following environment variable to the system variable, properties----environment variable---
    2. Add the PATH variable: C:\Software\eclipse_android\sdk\tools; (the path to the Tools folder in the SDK file you downloaded)
    3. Check the SDK, open the cmd window, enter Android–h to view the version information of the SDK, if any, the instructions are successful, otherwise follow the above steps to check

4.NDK Configuration

Due to the COCOS2DX platform, I intend to develop in C + +, so I have to configure the NDK

Development of Android App ToolkitLinux/Mac OS X 下NDK r10c,在AndroidDevTools也可以找到NDK下载,安装方法请戳

There is one more step to configure environment variables finally, it is important.

5.COCOS2DX Android Compilation Environment

Android compilation environment need to use ANDORID_SDK \android_ndk\ant and JDK, here, has only ant not, so go to ant website next to the latest: Ant download

Finally finish all the things that must be prepared, and immediately take a critical step:

First of all, it is recommended to change the sdk\ndk\ant path to sdk\ndk\ant this short name (in fact, I began to shorten, you if the variable problem, remember to modify the table to hit me, run quickly-")

This is to facilitate later use.

After finishing, we begin to configure:

    1. Before you have configured the JDK, you can check it again in cmd, and if not, you could go back and try again.
    2. Configure the environment variables for ant. Add the [ANT directory]\bin folder to path, such as: C:\Software\eclipse_android\ANT\bin (write by your own path)
    3. After the recommendation to run the Cocos2dx file in the Setup.py Association SDK NDK and Ant, the cmd interface will appear, follow the prompts to complete the SDK ndk and ant associations, or you can manually associate SDK Ndk and Ant.
      1. (Skip the 4th step if you pass the setup.py Association)
      2. Click to add the following environment variable to the system variable, properties----environment variable---
      3. ANDROID_SDK_ROOT:C:\SOFTWARE\ECLIPSE_ANDROID\SDK (fill in your SDK path)
      4. Ant_root:c:\cocos\tools\ant\bin (fill in your [Ant directory]\bin folder path)
      5. NDK_ROOT:C:\SOFTWARE\ECLIPSE_ANDROID\NDK (fill in your NDK path)
    4. After you complete the manual association, it is recommended to run the Cocos2dx file again setup.py, complete the other Cocos Association (blood and tears, not here crying)
    5. Rerun setup.py confirm that all the configuration is correct, the following figure will appear, the basic success, or you continue to check the environment variable
    6. Often someone reflects that the Cocos command cannot be bounced, so add C:\COCOS2DX to the path variable; (your cocos2dx directory path)
    7. Then we can compile the APK file in the project directory using Cocos compile-p Android--ap 18 way. Specific compile commands see cmd help yourself
6. Personal compilation Experience

Of course this is basically the end, in the conscience, or continue to reveal a little behind the pit

1. It is recommended that the following COM and org cocos2dx\cocos\platform\android\java\src be copied to the \PROJ.ANDROID\SRC path of your new project before compiling

For example: My project path: C:\COCOSDEMO\MY2048GAME\PROJ.ANDROID\SRC,COCOS2DX's adnroid src path C:\cocos2dx\cocos\platform\android\ Java\src

Then copy the COCOS2DX SRC package to the project SRC, otherwise the compilation cannot generate Gen folder, you know the consequences

2. Through the first step, you can avoid the Eclipse open project in the Android folder when the project does not have a Gen file error

3. Adding the SRC folder will not necessarily avoid the Gen file because it requires you to compile with the Cocos compile-p Android command before the Gen file

4. Experience therefore:

    1. Add the COM and org files below COCOS2DX\COCOS\PLATFORM\ANDROID\JAVA\SRC first
    2. Cocos compile-p Android Command compiled first
    3. Eclipse opens the project, compiles it again, and you'll see a beautiful picture on the real machine, then turn off Eclipse and write code on vs.

Above

Zhaolion

2015-02-08 14:18:09

COCOS2DX Series notes (2)-Windows environment Configuration subsequent Android environment configuration

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.