Cocos2d-x 3.1.1 Learning Log 11 -- a Windows Android environment to build (must be useful to you !!), 11 -- android

Source: Internet
Author: User

Cocos2d-x 3.1.1 Learning Log 11 -- a Windows Android environment to build (must be useful to you !!), 11 -- android
Installation Steps: (how painful !!) 1. Configure JDK

  • JDK:
  • Set environment variables:
JAVA_HOME = C: \ Program Files (x86) \ Java \ jdk1.7.0 _ 21 CLASSPATH =.; % JAVA_HOME % \ lib;Add Path % JAVA_HOME % \ bin;
Open cmd and enter java-version. If the following prompt is displayed, the environment variable is set successfully: C: \ Users \ arlin> java-version Java version "1.7.0 _ 21" Java (TM) SE Runtime Environment (build 1.7.0 _ 21-b11) Java HotSpot (TM) Client VM (build 23.21-b01, mixed mode, sharing)
2. Download the Android SDK

Google provides Android Developer Tools (ADT) for Android Developers, including the SDK and Eclipse.

3. Download Android NDK
4. Download ANT

5. Download Python
  • In the past, cocos2dx had to use different scripts to create and construct projects on different platforms. python was used in 3.0 and later versions. Therefore, the python environment needs to be installed in Windows:
I downloaded the latest version and found a syntax error when using setup. py. Therefore, it is best to use version 2.7.3, which has been tested by myself.
  • Configure environment variables: the latest version can automatically add the path environment variables, but 2.7.3 does not work, so we can only set it by ourselves. Assume that my Python is installed on: d: \ Python27 \
Add this path to the path environment variable. When we input python in cmd, the following words appear, which indicates that the environment variable is correctly set: C: \ Users \ arlin> python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>

Cocos2d-x download and configuration 1. Download cocos2d-x
I downloaded cocos2d-x3.1.1.
2. Set Environment Variables
These environment variables are configured through setup. py in the cocos2d-x root directory. We start cmd and run setup. py:
F: \ cocos2dx \ cocos2d-x-3.0rc0> setup. py
In this case, we need to provide the NDK, SDK, and ANT path for the script. We can enter the path according to the previous path. The entire command process is as follows: Setting up cocos2d-x...
-> Adding COCOS2D_CONSOLE_ROOT environment variable... OK -> Added: COCOS_CONSOLE_ROOT = F: \ cocos2dx \ cocos2d-x-3.0rc0 \ tools/cocos2d-cons Ole/bin
-> Looking for NDK_ROOT envrironment variable... NOT FOUND Please enter its path (or press Enter to skip): d: \ adt-bundle-windows-x8 6 \ android-ndk-r9d ADDED -- Added: NDK_ROOT = d: \ adt-bundle-windows-x86 \ android-ndk-r8e
-> Looking for ANDROID_SDK_ROOT envrironment variable... NOT FOUND Please enter its path (or press Enter to skip): D: \ adt-bundle-windows-x8 6 \ sdk ADDED -> Added: ANDROID_SDK_ROOT = D: \ adt-bundle-windows-x86 \ sdk
-> Looking for ANT_ROOT envrironment variable... NOT FOUND Please enter its path (or press Enter to skip): d: \ adt-bundle-windows-x8 6 \ apache-ant-1.9.3 \ bin ADDED -> Added: ANT_ROOT = d: \ adt-bundle-windows-x86 \ apache-ant-1.9.3 \ bin
Set up successfull: COCOS_CONSOLE_ROOT was added into registry NDK_ROOT was added into registry ANDROID_SDK_ROOT was added into registry ANT_ROOT was added into registry
Please restart the terminal or restart computer to make added system variables t Ake effect
The command prompts us to restart the terminal or the system to make these environment variables take effect. Generally, we can close cmd and the resource browser. If an error cannot be found in the environment variables, restart the system. To test whether the environment variables take effect, restart cmd and enter the following command to check whether the environment variables are normal: F: \ cocos2dx \ cocos2d-x-3.0rc0> set NDK_ROOT NDK_ROOT = d: adt-bundle-windows-x86 \ android-ndk-r8e
F: \ cocos2dx \ cocos2d-x-3.0rc0> set ANT_ROOT ANT_ROOT = d: \ adt-bundle-windows-x86 \ apache-ant-1.9.3 \ bin
F: \ cocos2dx \ cocos2d-x-3.0rc0> set ANDROID_SDK_ROOT ANDROID_SDK_ROOT = D: \ adt-bundle-windows-x86 \ sdk
F: \ cocos2dx \ cocos2d-x-3.0rc0> set COCOS_CONSOLE_ROOT COCOS_CONSOLE_ROOT = F: \ cocos2dx \ cocos2d-x-3.0rc0 \ tools/cocos2d-console/bin

Create and build a project 1. Create a project
We need to use the tools \ cocos2d-console tool to create a project, which provides the following features:
  • Create a new project
  • Compile compiles the current project and generates binary files. I personally think that writing to build is more appropriate.
  • Deploy a program to a platform
  • Run compile and release, and run the program

Now, in cmd, enter:
F: \ cocos2dx> cocos new mygame1-p com. colin. mbgame-l cpp-d f: \ cocos2dx \ mbgame
The following output is displayed: F: \ cocos2dx> python F: \ cocos2dx \ cocos2d-x-3.0rc0 \ tools \ cocos2d-console \ bin \/cocos. py new mygame1-p com. colin. mbgame-l cpp-d f: \ cocos2dx \ mbgameRuning command: new> Copy template into f: \ cocos2dx \ mbgame \ mygame1> Copying cocos2d-x files...> rename project name from 'hellocpp 'to 'myame1'> Replace the project name from 'hellocpp' to 'myame1'> Replace the project package name from 'org. cocos2dx. hellocpp 'to 'com. colin. mbgame'

This indicates that we have successfully created a project. The project directory structure is as follows: -- <Mygame1> -- <Classes> -- <Cocos2d> -- <Proj. android> -- <Proj. ios_mac> -- <Proj. linux> -- <Proj. win32> -- <Resources> Cocos-project.json. --CMakeLists.txt
We can see that all the projects under various platforms have been created, and it has copied the entire cocos2d framework. This kind of quality is wise,
2. Build an Android Project
At the same time is the use of cocos2d-console, here to use the compile command, in cmd enter the following to view help: F: \ cocos2dx \ mbgame \ mygame1>Cocos compile -- help
Usage: cocos compile [-h] [-s SRC_DIR] [-q] [-p PLATFORM] [-m MODE] [-j JOBS] [-- Ap ANDROID_PLATFORM] [-- source-map]
Now, in cmd, enter:
F: \ cocos2dx \ mbgame \ mygame1> cocos compile-p android-j 4

This means that we need to compile the Android project under the current directory and there can be four compilation tasks at the same time, so my 4-core machine will be fully occupied, if there is no accident, the compilation starts. If the following statements are displayed, the compilation is successful:
BUILD SUCCESSFUL
Total time: 7 seconds
Move apk to F: \ cocos2dx \ mbgame \ mygame1 \ bin \ debug \ android
Build succeeded.

We arrived F: \ cocos2dx \ mbgame \ mygame1 \ proj. android \ bin \You can see mygame1-debug.apk, indicating that the build is complete.
I installed it on my mobile phone and tried it. It seems that the startup speed is much faster. I wonder if it is a psychological effect.

In this process, ANT almost finds the cause of death:

The environment variable ANT_HOME is also the decompressed directory to Ant: ANT_HOME: E: \ Ant \ apache-ant-1.8.1 \ bin;

I'm dizzy !!! Guess what, the ANT_HOME configuration cannot add points; I have removed the semicolon and cannot add bin. Falk !! Hey hey ......


Don't understand can add my QQ group: 239982941 (cocos2d-x 3.1.1 Learning Group)


Cocos 2d 30 development environment after the establishment of the E: \ android-sdk_r14-windows-hagar \ cocos2d-

Yes, I am also doing Android, last month I also made a few days to build the eclipse Cocos2d-x environment, also encountered the same problem. You can refer to this: Build a cocos2d-x-android environment Windows XP3 + Eclipse + NDKR7 (or ndkr7b) + COCOS2DX (not used to cygwin and minigw) Address: blog.csdn.net/..261986

Cocos2d-x android environment to build the problem, ask the following question how to solve, spent two days to see countless web pages can not solve

Okay, so I am dealing with Android:
Because the Cocos2d-X is cross-platform, which of your create_project.py projects are all created when you create them, where Class and Resource are shared;

If it is developed on Mac, you can directly test Xcode, and finally build it with build_native.sh, and then pack Eclipse. If it is Windows, you can use VS for development and testing, and then use Eclipse for packaging;

Specifically, I did not develop it using Eclipse. I usually ended up packaging and releasing the apk;
You can refer to the tutorials of Yunlong. Although it is different from the latest version, the basic idea is as follows:
Www.cnblogs.com/...7.html



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.