Update: We need help testing v3.17 (it's only a few weeks away)

Update: We need help testing v3.17 (it's only a few weeks away)


@mars3142 I fully agree with you: everything including external libraries and cocos2d-x should be build from source code (no prebuilds *.dll, *.lib, *.a, at all in cocos2d-x\external only source code). External libraries source code should be committed to cocos2d-x repo (or added as git submodule)

I would like to add to wish list also:

  1. Building external libraries (from source code) should be configured for all platforms (Android/Win32/macOs/iOS) and unified (currently different platform e.g. Linux and Android use different versions of external libs).
  2. There should be easy way to reuse one build of external libraries and cocos2d-x between many games (currently “cocos gen-libs” + can be used for that)
  3. Full CMake support for all platform

I would like to have structure like below (with source code only):



and work with CMake only

$ mkdir build_android
$ cd build_android
$ cmake …
$ cmake --build --target my_game_1 . # build cocos2d-x and \cocos2d-x\external and my my_game_1
$ cmake --build --target my_game_2 . # reuse already compiled android cocos2d-x and \cocos2d-x\external build my_game_2 only


$ mkdir build_win32
$ cd build_win32
$ cmake …
$ cmake --build --target my_game_1 .
$ cmake --build --target my_game_2 . # reuse already compiled cocos2d-x and \cocos2d-x\external


Also make it easier to remove unused third-party libraries.

There should be #ifdef FEATURE_X around all code that requires the library in the manner that Chipmunk and others that currently allow disabling and then removing the library binary as well (from CMake or mk/project/solution).

Probably one or a few required, and those should be noted alongside the optional ones.

Edit: note that this is what cocos2d-lite is meant to achieve, at least in part, yet I think it’d be useful if not too much work to at minimum document how to do this on macOS/OSX and Windows for iOS/Android or all target platforms. I’ve also done this in a hack-y manner, which is not releasable, so it can be done. I mainly did this to get access to GLFW 3.2 before it was supported.


Just a question: will it be any improvements in audio module for android in 3.17? I talk about gapless looping larger files in AudioEngine.


Why we don’t use ndk r17?


You can use r17 by yourself. I switched my project from ndk build to cmake for Android with the lastest 3.17 github commit and it compiled error free.


If you install the NDK with Android Studio, if will be located within the Android SDK ndk-bundle folder. This folder is local.properties file in the proj.android folder.

You can download every other NDK from https://developer.android.com/ndk/downloads/older_releases - You only need to change the folder reference in the local.properties to the NDK of you choice.


Anyone could help me to test this issue? it need be solved before 3.17 released.


I can help with whatever you need.


Can you help me with gen-libs? It generates prebuilt libraries just fine, they work for iOS, but for android (switching from older cocos2d-x version) I’m getting following errors when trying to compile the app:

Traceback (most recent call last):

  File "/Users/piotr/sdk/ndk-bundle/build/import_abi_metadata.py", line 18, in <module>

    import argparse

zipimport.ZipImportError: can't decompress data; zlib not available

Android NDK: WARNING: Ignoring unknown import directory: /Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git/cocos/prebuilt-mk    

Android NDK: /Users/piotr/Documents/projekty/gry/Bee/proj.android-studio/Bee/jni/Android.mk: Cannot find module with tag './prebuilt-mk' in import path    

Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?    

Android NDK: The following directories were searched:    

Android NDK:         

*** Android NDK: Aborting.    .  Stop.

Here’s Android.mk file (I’ve removed most of cpp files to reduce size):

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := MyGame_shared



LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../../Classes/AppDelegate.cpp \
                   ../../../Classes/Utils.cpp \

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes


LOCAL_STATIC_LIBRARIES := cocos2dx_static



$(call import-module,./prebuilt-mk)


And… in 3.16 I had a directory cocos/prebuilt-mk, but it’s not present in 3.17

What’s wrong @slackmoehrle @drelaptop ?

edit: And most important part of build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.rosapp.bee"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.00"

        ext {
            cocospath = "/Users/piotr/Documents/pierdoly/cocos2d-x-3.17_git"

        externalNativeBuild {

            ndkBuild {
                targets "MyGame"
                arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk"
                arguments "-j" + Runtime.runtime.availableProcessors()
                abiFilters "armeabi-v7a"

    sourceSets.main {
        java.srcDir "src"
        res.srcDir "res"
        jniLibs.srcDir "libs"
        manifest.srcFile "AndroidManifest.xml"
        assets.srcDir "assets"

    externalNativeBuild {
        ndkBuild {
            path "jni/Android.mk"


Anything I can do specifically to help?


hmm, let me try to build them now.


I used the 3.17 branch and android gen-libs worked for me.


gen-libs works for me too, but I can’t build the app with them. Something in the structure changed, because prebuilt-mk directories are missing.


Until now I successfully used them and it worked.


@drelaptop do you know about this?


@piotrros @BuildFailed

Same problem trouble me, why we only have a gen-libs to gen prebuilt libraries, but didn’t have a option to use them. for example --use-libs, we will easy to use them if existed that option.

So how to use the prebuilt libs? I think we have to create a Android.mk to add the prebuilt libs, and include engine header files. and then use it in Gradle, it’s same as using 3rd-party prebuilt libs, a common issue to use libs by Android.mk, not a special Cocos2d-x problem.

In other side, we support cmake for the android native build in coming 3.17 release, also GitHub v3 latest code, CMake build supply another way to generate libs, and use those libs, just enable/disable option, not need to do hard works. Refer to cmake/readme to know how to use it. the gradle configs is,

// prebuilt root must be defined as a directory which you have right to access or create if you use prebuilt
// set "-DGEN_COCOS_PREBUILT=ON" and "-DUSE_COCOS_PREBUILT=OFF" to generate prebuilt, like "cocos gen-libs"
// set "-DGEN_COCOS_PREBUILT=OFF" and "-DUSE_COCOS_PREBUILT=ON" to use prebuilt, like "--use-libs"
// default behavior is both OFF, neither gen-libs nor use-libs.
arguments "-DCOCOS_PREBUILT_ROOT=/Users/laptop/cocos-prebuilt"

and please set PROP_BUILD_TYPE=cmake to enable cmake native build, refer to this in gradle.properties

# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk


you will have to rebuild pre-compiled libs if the source code of engine changes, I think not any better choice.

wonderful, using prebuilt isn’t necessary for using the engine.


Some notes about Windows versions (win32 and win10):
(would be great to have it include in a next update)

on Win10 & Win32:

  • add Box2D libs from 3.15 in cocos2dx-3.17/external (for Win32 need to configure the lib for recent version of SDK and Visual studio, also setted as dll instead of static lib but not sure of what I do)
  • add in project .vcxproj: code “4068” in DisableSpecificWarnings (debugs & releases nodes) (to avoid pragma mark warnings)

on Win10:

  • get the proj.win10 back (for now I copy a directory from a cocos2dx-3.15 proj.win10 generated project)
  • remove all libbullet references in the yourproject.sln and App/yourproject.vcxproj files (seems that some ref are also in libcocos on Win32)

on Win32:

  • add “$(EngineRoot);” in the 2 AdditionalIncludeDirectories (debug & release) (to get rid of some cocos-ext include issues)

  • change project properties-> c/c++ -> Debug Information Format C7 compatible(/Z7)
    ie in vcxproj
    for issues of kind “Internal Compiler Error: failed to write injected code block to PDB”

  • build-cfg.json is not supported, so could be deleted, in the .vcxproj file, use instead:
    xcopy “$(ProjectDir)…\Resources\your_path_one” “$(OutDir)” /D /E /I /F /Y
    xcopy “$(ProjectDir)…\Resources\your_path_two” “$(OutDir)” /D /E /I /F /Y

  • replace libcurl_impl.lib; by libcurl.lib; in release AdditionalDependencies in vcxproj


Any way to not use the prebuilt external and build it our self like in 3.16


You can use the source tree or run cocos gen-libs or do I not understand your question?