In the previous blog, we introduced the COCOS2D-X development environment under Windows and the Android development environment under Windows, today we introduce the Android development environment under Cocos2d-x.
Before setting up the Android development environment under Cocos2d-x, we must first build the Cocos2d-x development environment under Windows and the Android development environment under Windows.
If not set up these two environments can see my blog
Build the Cocos2d-x development environment under Windows: http://blog.csdn.net/u010105970/article/details/39525069
Build an Android development environment under Windows: http://blog.csdn.net/u010105970/article/details/39755745
Tools to prepare:
ADT (Android SDK with Eclipse)
Android NDK
Android phone
First create a cocos2d-x version of the HelloWorld project, the project directory is as follows:
Open the Resource folder in the HelloWorld project directory
Copy the resources in the resource folder to the HelloWorld project directory.
In the E:\game\cocos2d-x-2.2.3\projects\HelloWorld\proj.android\assets folder
Open the E:\game\cocos2d-x-2.2.3\cocos2dx\platform\android\java\src folder
copy org to E:\GAME\COCOS2D-X-2.2.3\PROJECTS\HELLOWORLD\PROJ.ANDROID\SRC
Start eclipse in the E:\game\adt-bundle-windows-x86-20131030\eclipse directory
Select File
Select InPort
Select Android
Choose existing Android Code into Workspace
Click Next
Click Browse
Select Proj.android under the HelloWorld project directory and click OK
Click Finish
Eclipse after importing the HelloWorld project
Select HelloWorld and right-click the mouse button
Select Refresh
Select Properties (Attributes)
Select C++build
Enter the full path of the ndk-build.cmd in the build command
E:\game\android-ndk-r9-windows-x86\android-ndk-r9\ndk-build.cmd
Select the environment configuration environment variable under the C + + build directory
Add environment variable, select Add
Add the first environment variable ndk_root,
Variable name (name): Ndk_root
Ndk_root Variable Value: E:\GAME\ANDROID-NDK-R9-WINDOWS-X86\ANDROID-NDK-R9 (ndk path)
Click OK when you are finished adding
Add two environment variables using the above method
Variable name: COCOS2DX
Variable Value: E:\game\cocos2d-x-2.2.3 (Path of Cocos2d-x)
Variable name: Ndk_module_path
Variable value: E:\game\cocos2d-x-2.2.3\; E:\game\cocos2d-x-2.2.3\cocos2dx\platform\third_party\android\prebuilt
Effects after adding a finish
Select Resource
Select Linked Resource
Select New
To set the resource load path:
Name:cocos2dx
location:e:\game\cocos2d-x-2.2.3 (Path of Cocos2d-x)
And then click OK
Click OK
Select Project
Select Build Project
Connect your phone with the data cable
Select Run as
Choose android Application
Execution Result:
Build Cocos2d-x's Android development environment under Windows