Installation and Configuration of Native Development Environment

    To publish to the Android platform, it is necessary to install all of the following development environments. If there is no need to publish to the Android platform, or if the operating system already has a full Android development environment, skip this section.

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

    Java SE Development Kit 8 Downloads

    Before downloading, make sure to select the operating system and architecture that matches the machine architecture and operating system. Run the installer after the download is complete.

    After the installation is complete, please confirm that the command is valid on the command line. Input the following code into Mac terminal or Windows command line tool to check:

    If JAVA SE is displayed, there is no problem. If JRE is displayed, then it is necessary to install the .

    On the Windows platform, confirm if JAVA_HOME is included in the system environmental variables. By right-clicking the Computer icon and choosing Property -> Advanced system settings -> Environment Variables to check and modify environmental variables. It may be necessary to restart the system after the changes are made before they take effect on the Windows platform. For details, please refer to the How do I set or change the PATH system variable? documentation.

    Cocos Creator does not support Eclipse’s ANT build, it is necessary to use Android Studio 4.1 and above as an Android platform’s build tool and download the required SDK and NDK packages in Android Studio. First, install .

    1. In the SDK Platforms tab page, check the API level you want to install, and it is recommended to select the required mainstream API Level such as API Level 26 (8.0), , etc.
    2. In the SDK Tools tab page, first check the lower right corner of the Show Package Details, to show the version of the tool selection.
    3. In the Android SDK Build-Tools, select the latest build tools version.
    4. Check the Android SDK Platform-Tools and CMake. To install the Android Support Library, please refer to the official Support Library Setup documentation.
    5. Check the NDK and the recommended version is r18~21.
    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.

    Please install the following runtime environment:

    • In Windows, the installation of is needed. When installing Visual Studio, please check Desktop development with C++ and Game development with C++ two modules.

    • On macOS, the installation of Xcode and the command-line tools are necessary.

    Next, go back to Cocos Creator to configure the environmental path of the native platform. Choose Cocos Creator -> Preferences in the main menu, and open the Preferences panel. We need to configure the following two paths here:

    preference

    • Android SDK: choose the Android SDK Location path just noted in Android Studio SDK Manager window (the directory of Android SDK should include folders like build-tools, platforms, etc.). Skip this if there is no need to compile for the Android platform.

    After the configuration is complete, Creator will automatically save it.

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

    1. Android built successfully, but prompts dlopen failed: cannot locate symbol "xxxx" referenced by "libcocos2djs.so"... in runtime.

    In the end, if build still fails, please send us feedback via the with Creator version, detailed reproduction steps, the build log file in the Build panel, and a demo that reproduces the problem.