Cocos2d-x 3.x deployed to Android

Source: Internet
Author: User

First, pre-preparation

Download the following software:

    • Python2.7 (https://www.python.org/downloads/)
    • Cocos2d-x 3.x (http://www.cocos2d-x.org/download/)
    • JDK (http://www.oracle.com/technetwork/java/javase/downloads/index.html)
    • ADT (https://developer.android.com/studio/index.html#downloads) [ contains Android studio and Android SDK]
    • NDK (https://developer.android.com/ndk/downloads/index.html)
    • ANT (http://ant.apache.org/bindownload.cgi)
Second, collocation environment variables
    1. Install Python

Then go to my Computer---properties---advanced system settings---environment variables

Locate the path variable in the system variable, edit and add the path to the root directory where Python is stored (note semicolon-delimited)

Test: Open cmd in any directory, enter Python, if the following version information appears, the installation succeeds:

2. Installing the JDK

The next step is OK, go to "environment variable" setting after completion

Create a new variable in the system variable:java_home, which stores the path of the root directory where the JDK resides

Find Classpath variable, add inside:;%java_home%\lib;


Test: Open cmd in any directory, enter Java-version, if the following version information appears, the installation is successful:

3. ADT

4. NDK and Ant only need decompression

Locate the path variable in the system variable, edit and add the paths to the root directory where the NDK resides,

and the path to the bin directory under the root directory of ant, which is the root of the ant \ Bin

5. Unzip the Cocos2d-x installation package

Open cmd and switch to extract directory, enter Python setup.py

You will then be prompted to enter the NDK, SDK, ant root directory and enter it as required (ant to enter its bin directory!). )

After all is done, close the command line, enter again, and enter:

Set Ndk_root

Set Ant_root

Set Android_sdk_root

Set Cocos_console_root

III. create the project and transplant it to Android
    1. Create a project

Input Cocos New project_name -P package_name -L language -D DIRECTORY

Project_Name, project name, such as Catapultgame

Package_name, package name, such as Com.labi.game

Language, language, can be CPP, LUA, JS

directory, catalog where the project resides

such as Cocos new catapultgame -P com.labi.game -L CPP -D F:\cocosExample

2. Transplant Android Platform

If you have a. cpp file that you have added yourself during the project, you need to modify the Android.mk file under the Proj.android/jni folder before packaging. apk.

Add your newly added CPP file

Open cmd and enter the directory where the project is located,

Enter Cocos compile-p Android to

Finally in the [Project folder]\bin\debug\android\ folder, you can find the APK file

Cocos2d-x 3.x deployed to Android

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.