Setup Native Development Environment

Apart from publish game to Web, Cocos Creator uses the JSB technology based on cocos2d-x engine for the cross-platform release of native games. Before using Cocos Creator to bundle and publish games to native platforms, you need to configure related cocos2d-x development environment first.

Android platform dependencies

To publish to the Android platform, you need to install all of the following development environments.

If you do not have a plan to publish to the Android platform, or if your operating system already has a full Android development environment, you can skip this section.

Android SDK 10 dependencies

Starting with v1.2.2, the default Android project template will specify the android-10 sdk platform version as the default target. For more information, see Pull Request Use API Level 10.

If you encounter build error like 'not found android-10', you can download Android SDK API Level 10 according to the description below.

If you need to change the target API Level, you can modify the built project file cocos/platform/android/java/project.properties:

target = android-10

Change android-10 to the other API Level you need.

Download and install Android Studio

Starting with v1.5, we support the latest version of Android Studio and companion building tools. We recommend Android Studio as an Android platform build tool and you should download the required SDK and NDK packages in Android Studio. First install Android Studio.

Download the SDK and NDK required to publish the Android platform

After installing Android Studio, refer to the official documentation and open the SDK Manager:

SDK Manager Instructions

  1. In the SDK Platforms tab page, check the API level you want to install, and choose the minimum compatible API Level 10 (2.3.3) and the mainstream API Level such as 17 (4.2) and 22 (5.1).
  2. In the SDK Tools tab page, first check the lower right corner of the Show package details, show the version of the tool selection.
  3. In the `Android SDK Build-Tools', select at least build tools version 25.
  4. Check the Android SDK Platform-Tools, Android SDK Tools and Android Support Library
  5. Check the NDK and ensure that the version is above 14.
  6. Take note of the path of Android SDK Location on top of the SDK Manager window. Later we need to fill in the location of the SDK in Cocos Creator.
  7. Click OK and follow the prompts to complete the installation.

Sdk manager

Download the Java SDK (JDK)

Compile the Android project requires a complete Java SDK tool on your local computer, download it at the following address:

Java SE Development Kit 8 Downloads

Download and pay attention to select the machine and the operating system and architecture, download the installation can be completed after the installation process.

Note : After the installation is complete, please confirm that the java command is valid on the command line. Otherwise, please refer to the following section to manually add the java executable file to your environment variable.

Install C++ compiling environment

The compiling tool Cocos Console in Cocos Framework needs the following running environment:

  • Python 2.7.5+, download page. Pay attention! Don't download Python 3.x version.
  • In Windows, the installation of Visual Studio 2015 or 2017 Community Edition is needed, download page
  • In Mac, the installation of Xcode and command line tool is needed, download page

Configure path in original release environments

Next, let's go back to Cocos Creator to configure the environmental path of the constructing release original platform. Choose document/preference in the main menu, and open the preference window:

preference

We need to configure the following three paths here:

  • Android SDK, choose the Android SDK Location path we just noted in Android Studio SDK Manager window. You can skip this if you don't need to compile the Android platform
  • NDK, choose the ndk-bundle folder in Android SDK Location path. You can skip this if you don't need to compile on Android platform
  • ANT(you can skip it if build with Android Studio), you should choose the downloaded and unzipped Apache Ant folder, The chosen path should include an executable file named ant.

Close the window after configuration is completed.

Note: The configure will work when build native project. If the configure not works(some Mac may occur this situation), please try to set these settings to System Environment manually: COCOS_CONSOLE_ROOT, ANT_ROOT, NDK_ROOT, ANDROID_SDK_ROOT.

Notes

We have received lots of feedback about original packing in the public beta, and some possible reasons are supplemented here:

  1. Check the path

    The path set up in preference settings should be guaranteed to be correct, for example: the path of ant should be set under the bin directory in the ant installation directory, the root directory of which is NDK, while the directory of Android SDK should include documents like build-tools, platforms, etc..

  2. Check NDK version

    Please use versions later than NDK r10c, and r10e version is recommended.

  3. On Windows platform, JAVA_HOME environmental variables need to be checked

    If using Windows platform, please confirm if JAVA_HOME is included in your environmental variables. By right clicking My Computer, choosing property and opening the advanced tab, you can check and modify environmental variables. For effective running on Windows platform, you might need to restart the computer.

  4. Check JAVA environment

    Input the following code into Mac terminal or Windows command line tool for check:

     java -version
    

    If JAVA SE displays, there is no problem. If JRE displays, then you need to install JAVA SE running environment.

  5. Check if the C++ compiling environment is correctly installed in Visual Studio

    When installing Visual Studio, the C++ compiling component is not ticked off by default. If Visual Studio wasn't installed, you need to install it and choose compiling components concerning C++.

  6. Package name issue

    Check the package name in the constructing release panel. Package names that include blank space, -, etc. are all illegal.

In the end, if zipping still fails, you can try to create a standard Cocos2d-x project and compile it. If the Cocos2d-x project is compilable and Cocos Creator couldn't be zipped, please send the bug to us by forum.


Continue on to read about Publising -> Native.

results matching ""

    No results matching ""