(1) Cocos2d-x 3.4 Final Windows and Android environment configuration

Source: Internet
Author: User
Tags android sdk manager

  1. Objective

    Recently started to contact Cocos2d-x, a cross-platform game development framework, and as with all frameworks, the first problem faced by newcomers is the configuration of the development environment. Here to record my configuration process, ready to check.

  2. Install package

    The required installation packages are as follows:

    Cocos2d-x 3.4, Address Http://cn.cocos2d-x.org/download#anchor2

    Android SDk, where I directly use the Android official development environment Android Studio, address https://dl.google.com/dl/android/studio/install/1.1.0/ Android-studio-bundle-135.1740770-windows.exe

    NKD,COCOS2D official recommended use of the r9d version, using r10d will not find Srand function error, address Http://dl.google.com/android/ndk/android-ndk-r9d-windows-x86_64.zip

    Eclipse, I'm using the latest Luna standard version, address http://ftp.neu.edu.cn/mirrors/eclipse/technology/epp/downloads/release/luna/SR2/ Eclipse-standard-luna-sr2-win32-x86_64.zip

    ADT, using Eclipse to develop an Android program requires an ADT environment, address https://dl.google.com/android/ADT-23.0.4.zip

    Jdk,java development environment, address http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-windows-x64.exe

    AVD arm support, the default Android emulator is not arm supported, need to download arm image, address https://dl.google.com/android/repository/sys-img/google_apis/ Sysimg_arm-21_r03.zip

    Visual Studio Community, which is a completely free version of the address http://download.microsoft.com/download/7/1/B/ 71ba74d8-b9a0-4e6c-9159-a8335d54437e/vs2013.4_ce_enu.iso

    The above installation package can not be downloaded to use My network disk, Link: http://pan.baidu.com/s/1kToVGv9 Password: fki3

    To prevent unnecessary errors, all directories are in English.

  3. Installing VS2013

    Go directly to the next step.

  4. Installing Cocos2d-x 3.4

    Unzip the package to E-drive, I am here to E:\Cocos\Cocos2d-x-3.4, use VS2013 to open the SLN solution in E:\Cocos\cocos2d-x-3.4\build, compile, run, and if you see the Cocos configuration is successful.

  5. Installing the Android SDK

    Since I am a downloaded Android Studio, installing the Android SDK installs directly, and note that I chose E:\android when I chose the Android SDK installation path.

    Create a new test project after installation test the Android SDK is installed correctly.

  6. Installing the NDK

    Unzip to the E:\Android directory.

  7. Install Eclipse

    Unzip directly into any directory.

  8. Installing ADT

    Run Eclipse and select Help->install New software from the menu.

    In the top right corner of the popup dialog box, select Add ... Button.

    In the pop-up dialog box, name Enter ADT Plugin, and in archive, select the ADT package to download.

    Developer Tools before the next step, the installation will restart eclipse after completion.

    After reboot will let choose android SDK path, I here is E:\android\SDK.

    At this point, Eclipse's Android environment is installed.

  9. Configure environment variables

    New environment variable: java_home value is: D:\Program files\java\ jdk1.7.0 

    New environment variable: CLASSPATH value is:.; %java_home%\lib; (Note: The dot indicates the current directory, cannot be omitted)  

    Adds the following to the value of the system variable path:%java_home%\bin; (note: The semicolon here cannot be omitted) here, the JDK is installed.

    New environment variable: ANDROID_SDK value: E:\ANDROID\SDK

    Include the following in front of the value of the system variable path:%android_sdk%

    New environment variable: ndk_root value is: E : \android\android-ndk-r9d

    Adds the following in front of the value of the system variable path:% ndk_root%

  10. Create Cocos2d-x project

    Unzip the COCOS2D-X-3.2ALPHA0 compressed package you just downloaded into the folder you specified.

    Go to directory cocos2d-x-3.4/tools/cocos2d-console/bin/cocos.py

    Open terminal Run cocos.py script create file

     

    Python cocos.py new He Lloworld-p com.coco2dx.org-l cpp-d E:\cocos\projects

    Parameter description:

    Test for Project name

    -P Follow-up package name

    -L followed by development language type, with CPP, LUA, JS three types

    -D followed by project-hosted directory

    Build Android project file

  11. Import Android Project

    Finally, you can start Eclipse and import the Android project. The procedure is as follows:

    Right-click on "Package Explorer" and select "Import ..."

    When the dialog box appears, select "Exsiting Android Project into Workspace" (Import the existing Android projects into the workspace).

    The import will automatically execute the build_native.py script to compile. Once the compilation is complete, you can run HelloWorld in the real machine or emulator.

    Running in the emulator may prompt that the currently compiled APK can only be installed in an arm environment, only the downloaded arm image, and the Sysimg_arm-21_r03.zip into the Temp folder in the Android SDK directory. Then open the Android SDK Manager in Eclipse and select the following to install the local image file.

    This completes the environment configuration for the entire Cocos2d-x 3.4 release.

  12. let NDK automatically compile all files in the classes directory

    In large projects, the source files hundreds of thousands, with the following android.mk file, you do not have to add a source file.

    Local_path: = $ (call My-dir)

    include $ (clear_vars)

    $ (Call Import-add-path,$ (Local_path)/. /.. /cocos2d)

    $ (Call Import-add-path,$ (Local_path)/. /.. /cocos2d/external)

    $ (Call Import-add-path,$ (Local_path)/. /.. /cocos2d/cocos)

    Local_module: = cocos2dcpp_shared

    Local_module_filename: = Libcocos2dcpp

    # functions that traverse directories and subdirectories

    Define Walk

    $ ( Wildcard $ (1) ) $ (foreach E, $ (wildcard $ (1) ) $ (call Walk $ (e) )

    Endef

    # Traverse Classes Catalogue

    Allfiles = $ (call Walk, $ (Local_path)/. /.. /classes)

    file_list: = Hellocpp/main.cpp

    # extract all of the files from all . cpp file

    File_list + = $ (Filter %.cpp, $ (allfiles))

    Local_src_files: = $ (file_list:$ (Local_path)/%=%)

    Local_c_includes: = $ (local_path)/... /.. /classes

    # _cocos_header_android_begin

    # _cocos_header_android_end

    local_static_libraries: = Cocos2dx_static

    # _cocos_lib_android_begin

    # _cocos_lib_android_end

    include $ (build_shared_library)

    $ (Call Import-module,.)

    # _cocos_lib_import_android_begin

    # _cocos_lib_import_android_end

(1) Cocos2d-x 3.4 Final Windows and Android environment configuration

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.