Cocos2d-x environment setup for eclipse

Source: Internet
Author: User

Cocos2d-x environment setup for eclipse

Install Cygwin and add the NDK_ROOT environment variable to Cygwin's Home/(user)/. base_profile.
NDK_ROOT =/cygdrive/d/Android/android-ndk-r8e.
Export NDK_ROOT


Open the cocos2d-x unzip the root directory and find the file create-android-project.bat open.
See these lines
: Modify it to work under your environment // modify this directory to point to your Cygwin bin directory
Set _ CYGBIN = e: \ cygwin \ bin
If not exist "% _ CYGBIN %" echo Couldn't find Cygwin at "% _ CYGBIN %" & pause & exit 4
: Modify it to work under your environment // modify this directory to point to the tools directory of your Android sdk
Set _ ANDROIDTOOLS = e: \ android-sdk \ tools
If not exist "% _ ANDROIDTOOLS %" echo Couldn't find android sdk tools at "% _ ANDROIDTOOLS %" & pause & exit 5
: Modify it to work under your environment // modify this directory to point to your NDK root directory
Set _ NDKROOT = e: \ android \ android-ndk-r8
If not exist "% _ NDKROOT %" echo Couldn't find ndk at "% _ NDKROOT %" & pause & exit 6






Double-click to run the create-android-project.bat file first prompts you to enter the package name, then the project name, the last sdk version
Created successfully, you will see your new project under the root directory of the cocos2d-x
The Classes, proj. android, and Resources directories are in the C ++ source code directory, proj. android is the Android project, and Resources is the Resource Directory.
Add a sentence to proj. android/jni/Application. mk of the corresponding project.
APP_CFLAGS + =-Wno-error = format-security


Compile the project, open Cygwin, enter the newly created android root directory, and run the build_native.sh file (enter./build_native.sh). This is a compilation process until the compilation ends.
Import the Android project to Eclipse








Problem description:
After build_native.sh runs successfully, this problem occurs after the project is imported to eclipse. the following files cannot be found:
Import org. cocos2dx. lib. Cocos2dxActivity;
Solution:
1. just copy the cocos2dx/platform/android/java/src folder under the root directory of the cocos2d-x engine to the src package of the project.
2. You can also import the cocos2dx/platform/android/java project to generate a jar file and add it to the libs folder of the project.
Both methods will copy the dependency to the apk when it is generated.

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.