Cocos2d-x3.0 Android environment Configuration

Source: Internet
Author: User

After reading various blogs on the internet, either it's too old or I still can't do it. I only have to do it myself. Here is a solution: first, the most authoritative official document! After a cross-platform project is created using py, proj is generated. android folder, which contains a file README. follow the steps below to start md: #### Setup Eclipse Environment (only once) ** NOTE: ** This step needs to be done only once to setup the Eclipse environment for cocos2d-x projects. skip this section if you 've done this before. 1. download Eclipse ADT bundle from [Google ADT homepage] ( http://developer.android.com/sdk/index.html ) ** OR ** Install Eclipse with Java. Add ADT and CDT plugins. 2. Only for Windows 1. Install [Cygwin] ( http://www.cygwin.com/ ) With make (select make package from the list during the install ). (You can search for other blog posts in this step. Make sure the installation is successful.) 2. add 'cygwin \ bin' directory to system PATH variable. 3. add this line 'None/cygdrive binary, noacl, posix = 0, user 0 0' to 'cygwin \ etc \ fstab' file. 3. set up Variables: 1. path Variable 'cocos2dx ': * Eclipse-> Preferences-> General-> Workspace-> ** Linked Resources ** Click ** New ** button to add a Path Vari Able 'cocos2dx 'pointing to the root cocos2d-x directory .! [Example] ( https://lh5.googleusercontent.com/-oPpk9kg3e5w/UUOYlq8n7aI/AAAAAAAAsdQ/zLA4eghBH9U/s400/cocos2d-x-eclipse-vars.png ) 2. c/C ++ Environment Variable 'ndk _ root': * Eclipse-> Preferences-> C/C ++-> Build-> ** Environment **. * Click ** Add ** button and add a new variable 'ndk _ root' pointing to the root ndk directory .! [Example] ( https://lh3.googleusercontent.com/-AVcY8IAT0_g/UUOYltoRobI/AAAAAAAAsdM/22D2J9u3sig/s400/cocos2d-x-eclipse-ndk.png ) * Only for Windows: Add new variables ** CYGWIN ** with value 'nodosfilewarning' and ** SHELLOPTS ** with value 'igncr '4. import libcocos2dx library project: 1. file-> New-> Project-> Android Project From Existing Code.2. Click ** Browse ** button and open 'cocos2d-x/cocos2dx/platform/android/Java' directory.3. Click ** finish ** to add project. #### Adding and running from Eclipse! [Example] ( https://lh3.googleusercontent.com/-SLBOu6e3QbE/UUOcOXYaGqI/AAAAAAAAsdo/tYBY2SylOSM/s288/cocos2d-x-eclipse-project-from-code.png )! [Import] ( https://lh5.googleusercontent.com/-XzC9Pn65USc/UUOcOTAwizI/AAAAAAAAsdk/4b6YM-oim9Y/s400/cocos2d-x-eclipse-import-project.png ) 1. file-> New-> Project-> Android Project From Existing Code2. ** Browse ** to your project directory. eg: 'cocos2d-x/cocos2dx/samples/Cpp/TestCpp/proj. android/'3. add the project 4. click ** Run ** or ** Debug ** to compile C ++ followed by Java and to run on connected device or emulator. it's not over yet. Some things are ignored in the official documents. Cocos2d-x-3.0 \ projects \ *** \ proj. the android/src file is empty and does not have java code, copy the files in the cocos2d-x-3.0 \ cocos2dx \ platform \ android \ java \ src folder to the cocos2d-x-3.0 \ projects \ *** \ proj. android \ src. Then modify cocos2d-x-3.0 \ projects \ MyAirplaneGame \ proj. android \ jni \ Android. mk if other files are created in the classes folder in your project, add them here: for example, LOCAL_SRC_FILES: = hellocpp/main. cpp \.. /.. /Classes/AppDelegate. cpp \.. /.. /Classes/HelloWorldScene. cpp \ if you add any class, add it in the above format. OK. The compilation is successful. Nima! This is all.

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.