Http://www.cnblogs.com/graphicsme/archive/2012/11/06/2756914.html
After one day, I read the configurations written by many people, but none of them can solve all the problems. Here we will record the installation and configuration process, problems encountered, and solutions.
1. install Java JDK and eclipse
IDE
Install the Basic Java programming environment. For details, refer to here.
2. Install the android SDK
The installation path must not contain spaces!
After the installation is successful, the eclipse interface will display three more buttons marked above. Click the first button to select the Android version to be installed.
3. Install ADT (Android development tools)
Choose eclipse> help> install new software> Add, enter "ADT plugin" in the name column, 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 in sequence, and configure the SDK path (step 1), for example, "C: \ Users \ Andy \ appdata \ Local \ Android-SDK"
Configure AVD (Android Virtual Machine): select the second button in the first figure and configure relevant parameters. Click Start to view the effect.
Now we can use Java for Android development! But our goal is to use Cocos2d-x, C ++ development, we have to continue.
4. Install ndk
Ndk can make part of the android program code with C/C ++ implementation, for the subsequent installation of Cocos2D-x to prepare. Extract the package to a path without spaces. For example, E: \ cocos2d-x \ android-ndk-r8b"
5. Install cygwin
Cygwin simulates the Linux compiling environment in windows and supports cross-platform development. For details, refer to this blog.
6. Install Cocos2d-x
The latest cocos2d-2.0-x-2.0.4 I selected, decompress it to a path that does not contain spaces, such as E: \ cocos2d-x \ cocos2d-2.0-x-2.0.4 ".
Open the "cocos2d-win32-vc2010.sln" Compilation, you can try the trial run demo is not a problem
Double-click install-templates-msvc.bat to generate a vs 2010 (2008) Project template for Win32 projects. In fact, when developing Android or IOS apps in the future, the underlying layer is Win32 development created using C ++, but different configurations and compilation environments are available when it is finally released to different platforms. For example, the directory structure of the routine moonwarriors is:
Classes contains C ++ code, and the main part of the project is also the cross-platform part. Proj. Win32 is to use vs to develop a small amount of code and engineering configuration on the Win32 platform. Proj. Android and proj. IOS are the project files generated on the corresponding platform. Ndk is used to compile C ++ code and generate library files (libgame. so), you can imagine proj. A small amount of code in Android may be loading libgame. so let him run on the Android platform. The following describes how to generate the configuration of proj. Android.
7. Create an android project.
- Modify the create-android-project.bat file under the cocos2d installation directory. Set _ cygbin, _ androidtools, and _ ndkroot to the bin directory (C: \ cygwin \ bin) of cygwin and the tools directory of Android SDK (C: \ Users \ Andy \ appdata \ Local \ Android-SDK \ tools), ndk root directory (E: \ cocos2d-x \ android-ndk-r8b ).
- Run create-android-project.bat to generate the android project, input as required, and finally generate the entered project name directory under the root directory of cocos2d, such as helloworld ".
- Use the cygwin client to enter proj under helloworld. run build_native.sh In the android directory. If you are prompted that ndk_root is not defined, you can set it in the Windows environment variables. (Some people say that the Linux environment variables are needed here, the definition in Windows is useless. In fact, it is okay. If you try some other methods, it may be related to the latest version of the package I downloaded ). If there is no error, the last thing left is to use eclipse to compile the Java code.
- Eclipse> File> New> Project> Android project from existing code. Select the proj. Android path under helloworld. Select a project and choose run as> Android Application.
- If a compilation error prompt does not recognize cocos2dx, You Can Properties> JAVA build path> link source, 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 is successful, the helloworld interface is displayed. I keep running errors in the simulator. Later I found that the simulator does not support gles2.0, and there is no problem with the real machine.
Update: using this blog (porting Win32 games to the Android platform under win7), you do not need to run native_build and compile it in eclipse directly.
You can start android game development.