Cocos2d-x Android Development Environment (Windows + eclipse + ndk do not use cygwin) cocos2dx2.0

Source: Internet
Author: User

From http://www.cnblogs.com/ybgame/archive/2012/06/07/2540693.html

[I wrote it before] The environment is set up in this way. 1.jdk& JRE will install JRE along with JDK. This step aims to write and allow common Java Program 2. eclipse Java IDE, this step is to facilitate the development of Java program 3.cdt is a plug-in of Eclipse, this step is to introduce C ++ 4.adt is a plug-in of Eclipse, this step is to manage the android Development Library 5.adk. The previous step is the tool, and this step is the development library. At this step, you can compile a general Android program 6.ndk with a single CDT. It can only be edited, it cannot be compiled. This step is to compile the C ++ program and then use cygwin in Android, we use the new version of ndk to compile C ++ [install JDK 2] the latest version of JDK is 1.7. [important] Download JDK 1.6. JDK automatically contains JRE, use jdkcocos 1.7 Code There will be "temporary compilation errors" Download and installation are all the way to next, the following content is the method of downgrading 1.7 after the installation of 1.6, the direct installation of 1.6 can float : Bytes Java
Se Development Kit 6u30

If you have installed 1.7 as unfortunately as I do, you can use the following method to restore to 1. 61. Open windows preferences and set compiler compliance level to 1.6.

Then, you will be asked to configure JRE.

 

Add the JRE directory to configure JRE, and then select

Here, we have set jre6 and JDK for compilation in eclipse, but we cannot set your project next, open project properties, add library, and next, next, you need to select the JRE path.

Here we select jre6 set in Windows preferences, and then finish.

Now you will find more red forks and all files have red forks. Let's remove them. This is very simple. When I reset JRE, I reset android.

After you hook up Android adk, You Can [install eclipse and CDT] Here I use this one directly, with the CDT plug-in, already have eclipse students can download a cdteclipse decompression can be used directly, here do not ink eclipse C ++ version http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers-includes-incubating-components/indigosr2 [four install ADT] Two installation methods, online installation, download and installation, and network speed problems I prefer to download and install. Note: Please download the ADT of version 1.7 and later. Here, use version 1.8 In help and select install new software...

Select Add. For online installation, enter HTTPS : // Dl-ssl.google.com/android/eclipse/ (If not, change HTTPS to HTTP) To download and install the SDK, first download the SDK to your local device, then press archive to select the ADT path, click OK, and check the Developer Tools for installation. ADT 1.8 address: http://dl.google.com/android/ADT-18.0.0.zip PS. This installation takes some time... don't think it is dead. If your machine or network is not powerful, it will make you feel impatient. Please do not force close it... otherwise, you may want to see the following troubleshooting Restart eclipse after installation, and then prompt you to install adk

If you have unfortunately installed ADT of version 1.6 and earlier, or forcibly interrupted its installation, You Need To uninstall it.

It will not be able to create an android project, but uninstalling it is also a troublesome thing. First, you need to delete this plug-in, find the corresponding ADT in the help about, and then delete it.

Next, delete our ADT from the software update list.

[5. Install adk] After installing ADT, you will be prompted to install adk when you restart eclipse. You can specify the path or download and install adk plugin at this address.

[6. Install ndk] so far, we can use eclipse to compile Android programs, but our goal is to write Cocos in C ++, the last step -- ndk has two purposes: compile our c ++ code into a link library, where the link library is the so or a file in Linux, different from Windows DLL, the second objective is JNI. Java needs to use JNI to call our c ++ code: idea. First, we need to create an android project.

With the latest Cocos2d-x, we use his helloworld for testing.

After the project is opened, there is an error. There is no seteglcontextclientversion method. Here, comment it out for the time being. It indicates setting the version of OpenGL ES .... it should be okay by default.

Then, the console outputs a sentence.

App_platform: = Android-4 is added to application. mk.

Next we will add the ndk, let the ndk to compile our c ++ to specify the ndk-build.cmd to compile our project, the following working path will be passed into the ndk-build.cmd as a parameter, we select the project path, which will automatically compile Android under the JNI subdirectory. mk at this time if it is cocos2d-1.0.1-x-0.13.0-beta and the previous version, can be compiled, but if it is later versions, there may be the following error android. MK references a module, the cocos2dx module, and ndk does not find it. Therefore, this error is reported. In the previous version, Android directly contains the cocos2dx module. MK, so there will be no error. Here we use import, we can also use the method of the previous version to include it, but it seems that the import method is better than the previous method, some error information prompts us, you can set the ndk_module_path environment variable, It is very likely that the settings are incorrect. Generally, an android. MK contains one or more modules. When you want to import the cocos2dx module, it will find android in % ndk_module_path \ cocos2dx. MK file, so we edit our builder

Add the ndk_module_path variable, note to write two paths, separated by semicolons D: \ SDK \ cocos2d-2.0-rc0a-x-2.0; D: \ SDK \ cocos2d-2.0-rc0a-x-2.0 \ cocos2dx \ platform \ third_party \ Android \ prebuilt because cocos2dx has also imported several other modules, the second path has developed a third-party module, after setting can be compiled

I am using the latest 2.0, some header files are not found, and some types also have problems... close to hundreds of errors... Let's try to use a lower version. Next, another problem occurs that the static library cannot be found.

Copy libgnustl_static.a under the <ndk>/sources/cxx-STL/gnu-libstdc ++/libs/armeabi/directory to the OBJ/local/armeabi/libgnustl_static.a directory.

Put the last generated APK in the bin directory. Put the PS. Resource file under assets. The ADT will package it into the APK.

 

Related Article

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.