| Copyright Notice: This article for Bo Master original article, without Bo Master permission not reproduced.
1. Download and install Android (Android) environment
See http://www.cnblogs.com/geore/p/5793620.html, follow these steps to configure the environment variables for the Apache-ant,adt and NDK.
apache-ant:http://ant.apache.org/bindownload.cgi
ndk:http://wear.techbrood.com/tools/sdk/ndk/
adt:http://www.androiddevtools.cn/
2. Download and install the JDK
Jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
After the download is complete, install the JDK. As shown in the following:
Once installed, start configuring the JDK's environment variables, such as:
(1), the system variable in the new Java_home variable, the value of the variable is:
C:\Program files\java\jdk1.8.0_05 (fill in according to your own installation path)
(2), the new system variable CLASSPATH variable, the value of the variable is:
.; %java_home%\lib;%java_home%\lib\tools.jar (Note the previous.) Don't forget it)
(3), in the system variable path variable (existing without new) Add Variable value:
%java_home%\bin;%java_home%\jre\bin (Note the value of the variable with ";" Separated
Configuration Lib\tools.jar;
Configuration Jre\bin
Configuration bin
After configuring the environment variable, press Win+r to enter CMD, and in the Black window enter Java to see if the JDK environment variable is configured successfully:
3. Start packing
(1), in the Proj.android directory of the project file in the JNI we find the android.mk file. Open it, and in the Android.mk file, add our own newly written class file. As shown in the following:
(2), and then copy the Android.mk file to the Proj.android directory under the project directory. At the same time, hold down the shift+ right mouse button in this directory and choose to open the Command window here.
(3), in the Command Window input Cocos Package apk command: Cocos compile-p Android
Such as:
Package Start:
After the package is complete, a bin\debug\android folder will be generated under the project directory, and we can find the packaged apk file in it. Such as
Cocos2d-x Pack Android APK