"Winows7+android-ndk-r9+cygwin" COCOS2DX 2.* game porting Android Platform complete brochure

Source: Internet
Author: User

In order to have a lot of detours to go. Here is a brief record of the construction of the cocos2d development environment, the Android development environment, and the Android NDK environment. Finally realize COCOS2DX 2.* game Android platform porting.

Reprint Please specify the Source: http://blog.csdn.net/oyangyufu/article/details/24498213

COCOS2DX 2.* Games required for Android platform porting

1, cocos2d development environment to build, see the previous written documents: http://blog.csdn.net/oyangyufu/article/details/24009141

2, the Android development environment to build. See document:http://download.csdn.net/detail/oyangyufu/7251299

3, installation package preparation:

Android-ndk-r9-windows-x86_64.zip: http://developer.android.com/tools/sdk/ndk/index.html

Setup-x86_64.exe: http://www.cygwin.com/

Android NDK Overview

NDK Full Name: Native development Kit.

1. The NDK is a collection of tools.

* The NDK provides a range of tools to help developers develop a dynamic library of C (or C + +) at a high speed, and to package the so and Java applications together as an APK on their own initiative. These tools are a huge help to developers.

* The NDK integrates a cross compiler. and provides the corresponding MK file isolation CPU, platform, ABI and other differences. Developers simply need to make a simple change to the Mk file (stating "which files need to be compiled," "Compile feature requirements," etc.) and can create so.

* The NDK is able to package the so and Java applications on its own initiative, greatly reducing the developer's packaging work.

Unzip Android NDK to:

D:\android-ndk-r9-windows-x86_64\android-ndk-r9

setup-x86_64 Installation

Steps:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

The desktop will have a shortcut after installation: There will be a folder under the installation folder D:\cygwin64. Equivalent to creating a small Linux system:

test Cygwin64, Cygwin64 terminal Open input gcc-v, such as the following proof of success:

Configuring CYGWIN64 Environment variables

Open the. Bash_profile profile to define the ndk_root,cocos2d_root variables, allowing users to read this variable on their own every time they log in to the system

$ VI. Bash_profile at the end of the join for example:

Save and restart the terminal.

Change Project C + + file path

Open/cygdrive/e/cocos2d-x/cocos2d-x-2.2.3/projects/testlianliankan/proj.android/jni/android.mk, change local_src_ The files variables are:

Local_src_files: = hellocpp/main.cpp \
.. /.. /classes/appdelegate.cpp \
.. /.. /classes/helloworldscene.cpp \
.. /.. /classes/gamelayer.cpp \
.. /.. /classes/gbktoutf8.cpp \
.. /.. /classes/maplayer.cpp \
.. /.. /classes/mapnode.cpp \
.. /.. /classes/pauselayer.cpp

Compiling Cocos2d-x Game Project Android version number

Go to the project folder and run the compile script. For example, the following:

It takes about 10 minutes to compile and generate the libcocos2dcpp.so file under Libs/armeabi, such as the following:

Finally, import the COCOS2D project into the configured NDK eclipse to build the APK package.

Configure Android NDK ring :

Open Eclipse. Select window->preferences To configure the NDK path:

porting Libraries and resources

1. Copy the E:\cocos2d-x\cocos2d-x-2.2.3\cocos2dx\platform\android\java\src under Org to E:\cocos2d-x\cocos2d-x-2.2.3\ PROJECTS\TESTLIANLIANKAN\PROJ.ANDROID\SRC below. to be able to find the COCOS2D library when importing cocos2d projects.

2. Copy the resources under E:\cocos2d-x\cocos2d-x-2.2.3\projects\testlianliankan\Resources to E:\cocos2d-x\cocos2d-x-2.2.3\projects \testlianliankan\proj.android\assets below.

Project is imported into project compilation

Open Eclipse, File->import

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Tick the item you want to import. Finish.

Right-click this migration Androidproject and select Properties. Then choose Builders->new->programin the Mian page, fill in the NDK compilation path and the Localproject path, for example:D:\android-ndk-r9-windows-x86_64\android-ndk-r9\ndk-build.cmd on the Environment page, the new environment variable:Fill in:Ndk_module_pathE:\cocos2d-x\cocos2d-x-2.2.3; E:\cocos2d-x\cocos2d-x-2.2.3\cocos2dx\platform\third_party\android\prebuilt.Tick the New_builder option. Tick to CDT Builderthen OK, start run.since the previous script has been compiled. At this point, you do not have to wait for the straight pull. So to generate the APK package, the package is in the project's Bin folder, after generating their own active emulator can see your game. Of coursedebugging with the simulator is too slow, it is recommended to use the real machine debugging, to this is done! Drawings:

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvb3lhbmd5dwz1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

"Winows7+android-ndk-r9+cygwin" COCOS2DX 2.* game porting Android Platform complete brochure

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.