Cocos2d-x +android + Windows 7

Source: Internet
Author: User

Tossing the day, looked at a lot of people to write the configuration, but no one seems to solve all the problems. Here is a note of my installation configuration process, problems encountered, and workarounds.

1. Installing the Java JDK and Eclipse IDE

Basic Java Programming Environment installation, specific reference here.

2. Install the Android SDK

The installation path does not include spaces!

After successful installation, the Eclipse interface will have more than three buttons labeled above, click the first button to select the Android version you want to install.

3. Installing ADT (Android development Tools)

eclipse >  Help > Install New software > Add , enter "ADT Plugin" in the Name field, enter "https://dl-ssl.google.com/android/eclipse/" in the Address bar, and select OK. Then select Developer tools to install

Configure ADT: Window > Preferences > Android, configure the SDK path (2nd step), e.g. "C:\USERS\ANDY\APPDATA\LOCAL\ANDROID\ANDROID-SDK"

Configure AVD (Android virtual machine): Select the second button in the first graph to configure the relevant parameters. Click Start to see the effect.

Here you can use Java for Android development! But our goal is to use Cocos2d-x, C + + development, still have to continue.

4. Installing the NDK

The NDK allows some of the code in the Android program to be implemented in C/C + +, ready to install cocos2d-x later. Extract the compressed package to a path that does not include spaces. such as "E:\cocos2d-x\android-ndk-r8b"

5. Installing Cygwin

Cygwin simulates a Linux build environment in a Windows environment and supports cross-platform development. Refer to this blog for details.

6. Installing Cocos2d-x

I selected the latest version of cocos2d-2.0-x-2.0.4, extracted to a path that does not contain spaces, such as "E:\cocos2d-x\cocos2d-2.0-x-2.0.4".

Open "Cocos2d-win32-vc2010.sln" compile, you can try to run the demo there is no problem

Double click on" Install-templates-msvc.bat "to generate vs 2010 (2008) project template, easy to create Win32 project. In fact, when developing Android or iOS applications, the bottom layer is created in C + + WIN32 development, but finally published to different platforms, there are different configuration and compilation environment. For example, the directory structure of the routine moonwarriors is:

classes inside C + + code, The main part of the project is also a cross-platform part. Proj.win32 is the development of a small number of related code and engineering configurations with VS on the Win32 platform. The proj.android and Proj.ios are the project files under the corresponding platform generated. The NDK is involved in the compilation of C + + code and generates a library file (libgame.so) that can be used under the Android platform, and it can be imagined that a small amount of code inside the proj.android might be loading libgame.so let him run on the Android platform. The following is the configuration for generating proj.android.

7. Create an Android project.

  • Modify the "Create-android-project.bat" file under the Cocos2d installation directory. _cygbin, _androidtools, _ndkroot Three are set to the Cygwin Bin directory (C:\cygwin\bin), the tools directory of the Android SDK (C:\Users\Andy\AppData\ Local\android\android-sdk\tools), NDK root directory (E:\cocos2d-x\android-ndk-r8b).
  • Run "Create-android-project.bat" to build the Android project, enter it on demand, and eventually, in the root directory of cocos2d, will produce the project name directory you entered, such as "HelloWorld".
  • Use the Cygwin client to enter the Proj.android directory under HelloWorld, run build_native.sh, if the prompt does not define ndk_root, Can be set in the environment variables of windows (online, some people say that the need is a Linux environment variables, the definition of Windows is useless, the fact is, it is possible to try some other methods are useless, and I download is the latest version of the package has a relationship). Without errors, the last thing left is to compile the Java part code with eclipse.
  • Eclipse > File > New > Project > Android Project from Existing Code, select the Proj.android path under HelloWorld. Then select the project and select Run as > Android application.
  • If you have a compile error message that does not recognize COCOS2DX, you can choose Properties > Java Build path > Link Source and select E:\cocos2d-x\cocos2d-2.0-x-2.0.4\cocos2dx\ PLATFORM\ANDROID\JAVA\SRC path, name does not conflict with SRC.
  • If the operation succeeds, the HelloWorld interface pops up. I have been running in the simulator error, and later found that the simulator does not support gles2.0 caused by the real machine without problems.

Update: Use this blog (Win7 Win32 game to the Android platform) settings can not run Native_build directly in Eclipse build

Can start Android game development, starting from here.

Cocos2d-x +android + Windows 7

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.