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
- 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
- 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