[Cocos2d-x 3.0] Game Development of android cross compiling, cocos2d-xandroid
Author:Senlern
Reprinted please note, original link: http://blog.csdn.net/zhang429350061/article/details/37959489
In the previous article I shared such as in win32 configuration environment to build a project, did not see the children's shoes please look at this article: http://blog.csdn.net/zhang429350061/article/details/37958275
----------------------------------------- Download the JDK configuration environment variable ---------------------------------
Download URL: http://www.oracle.com/technetwork/java/javase/downloads/index.html
After the installation is successful, you need to configure the system environment variables:
New variable: CLASSPATH value :.
New variable: JAVA_HOME value: actual JDK installation path
Add % JAVA_HOME % \ bin in path (note the last semicolon)
---------------------------- Download the NDK configuration environment variable ---------------------------
: Http://developer.android.com/tools/sdk/ndk/index.html
After downloading the package, decompress it.
New variable: NDK_ROOT value: close to the decompressed path.
--------------------------- Start the command line to compile the android project ------------------------
First, cd to E: \ MyGame \ proj. android of your project in cmd, and then run the build_native.py script directly.
We can see the following output Select NDK toolchain version was 4.8! Great! The next step is the long compilation process.
Then there will be the following output:
After compilation, it looks like this:
Congratulations! Success
------------------------------------ Import the project to Eclipse and run it on your android phone ---------------------------------------
We directly use an integrated ADT, which has eclipse and android SDK: http://developer.android.com/sdk/index.html
After the download is decompressed, open eclipse.exe in the eclipsefolder to start Eclipse.
After the startup, click File-> New-> Project:
Then select Android Project From Existing Code:
Select the project's proj. android Directory from the Root Directory and click Finish.
Wait, is there a Red Cross at the project name? It seems that there is a mistake. What should I do ?? Haha:
Right-click the project engineering office and choose Import:
Then select the displayed options:
Then select the following path in the Root Directory (refer to your own path settings ):
Note: You can select only the first Project in the following Project. If you do not select any other Project, you can select Deselect All in the button on the right, select the first Project separately, and then Finish
No, it's amazing.
Now we can run it on our android phone. Right-click the Agency and choose:
A box for selecting a mobile phone is displayed. Double-click it:
Now we can see the output below the Console:
Is your game running on your mobile phone now ???!!!
Finally I will give you a small knowledge, if you want to view only the debug output of the cocos2d-x in logcat, you can click this green plus sign:
Then set this:
Then there is the sauce purple:
OK! It's much easier to view the debug information!
---------------------------------------- Remarks ------------------------------------
Limited capabilities. Please contact us. If you have any suggestions, thank you! (Let's talk about it)
Cocos2d-x + vs is it possible to develop android game?
The code developed by cocos2d-x on win32 platform also needs to be compiled to generate the package that android can use. For detailed operation, see this document.
Wenku.baidu.com/.. B .html
Another advantage of using the cocos2d-x engine is the ease of portability. Its C ++ code can be used as long as it is slightly changed on various platforms. The languages used by the ECLIPSE or Xcode environment alone are java and Object-c. If they are directly converted to each other, they must be much more difficult.
An error occurred while using ndk cross-compilation after cocos2d-x 201 generated the android Project
Because the eclipse version is incompatible with the ndk version, the ndk version you are using is relatively new. If r8e version exists, this problem is not solved, or you can. add the following code in mk: APP_CPPFLAGS + =-Wno-error = format-security. You can use the r8e package on your own. I will not advertise it.