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)
0.0 0

#61

@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):

dev
…\cocos2d-x
…\cocos2d-x\external
…\my_game_1
…\my_game_2

…\my_Game_N
…\CMakeLists.txt

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

or

$ 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


#62

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.


#63

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.


#64

Why we don’t use ndk r17?


#65

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.


#66

If I’m building project with ndkBuild using NDK 16.1.4479499 - should I update to 17.0.4754217 ? And how to switch back if it’s will not compile?


#67

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.


#68

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


#69

I can help with whatever you need.


#70

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_MODULE_FILENAME := libMyGame

LOCAL_ARM_MODE := arm

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

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,./prebuilt-mk)

# _COCOS_LIB_IMPORT_ANDROID_BEGIN
# _COCOS_LIB_IMPORT_ANDROID_END

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"
        }
    }

#71

Anything I can do specifically to help?


#72

I’ve also tried gen-libs for android, after ios, and I’m 100% can tell you - don’t try this at home. Don’t use gen-libs for android ever (


#73

hmm, let me try to build them now.


#74

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


#75

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.


#76

Until now I successfully used them and it worked.


#77

@drelaptop do you know about this?


#78

That’s their problem 50/50.


#79

@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"
arguments "-DGEN_COCOS_PREBUILT=OFF", "-DUSE_COCOS_PREBUILT=ON"

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
PROP_BUILD_TYPE=ndk-build

#80

My main experience that it’s always unstable and too much arguments need to set and checked and after some time\update - something will be broken, repeat. It’s complicated and takes time.
But using just “source code” option now all stable for me for a long time and so I will stay with this. Using prebuilts for ios mac only works same stable way.