cocos2dx V3.17.2版本编译

android studio 使用的是最新版本 3.4.1
ndk 是从里面默认下载的 19.2

命令打包的时候(cocos compile -p android)

提示2个错误。

/cocos2d-x/external/recast/…\json/document.h:969:80: error: too few arguments provided to function-like macro invocation
return (d >= static_cast(std::numeric_limits<int64_t>::min()))

/cocos2d-x/external/recast/…\json/document.h:969:26: error: static_cast from ‘std::__ndk1::numeric_limits::type ()() noexcept’ (aka 'long long ()() noexcept’) to ‘double’ is not allowed
return (d >= static_cast(std::numeric_limits<int64_t>::min()))

是不是我的NDK 有问题?
有没有大牛 发个cocos2dx lua 的 android studio 工程出来参考参考
谢谢了

没用过3.17.2,但是这版本没升级NDK,所以你要用16或者17编译
当然你也可以根据编译错误修改一下代码
编译说long long到double是不允许的,我看了下代码,把IsLosslessDouble这个函数删了把。

感谢你的回复
重新折腾了一边稀里糊涂的就把问题解决了… 新产物用的蛋疼啊

求大哥发一套你的cocos2dx v3.17.2编译通过的部鄹, 新手小白找了好些资料,全部失败,万分感谢

preboy@126.com

我就是因为3.17配置不好,用的3.16,我也不后悔反正都一样,3.17就提升了一个什么重画次数降低了耗电量,勾引不了我,我无所谓,我现在关系的是怎么把游戏装到玩家手机上

2赞

我这边使用了 cocos compile -m debug -p android -j 4 --android-studio 报错说 build-cfg不存在 我看了一下grade 配置 这个功能不是被写到这里了吗?
android.applicationVariants.all { variant ->
// delete previous files first
delete “${buildDir}/intermediates/assets/${variant.dirName}”

variant.mergeAssets.doLast {
    copy {
       from "${buildDir}/../../../../res"
       into "${buildDir}/intermediates/assets/${variant.dirName}/res"
    }

    copy {
        from("${buildDir}/../../../../../cpp-tests/Resources") {
            exclude "**/*.gz"
        }
        into "${buildDir}/intermediates/assets/${variant.dirName}/res"
    }

    copy {
        from "${buildDir}/../../../../src"
        into "${buildDir}/intermediates/assets/${variant.dirName}/src"
    }

    copy {
        from "${buildDir}/../../../../../../cocos/scripting/lua-bindings/script"
        into  "${buildDir}/intermediates/assets/${variant.dirName}/src/cocos"
    }

    // compile & encrypt the scripts if necessary
    def compileScript = (variant.name.compareTo('release') == 0)
    if (project.hasProperty('PROP_COMPILE_SCRIPT')) {
        compileScript = (PROP_COMPILE_SCRIPT.compareTo('1') == 0)
    }

    def encryptLua = project.hasProperty('PROP_LUA_ENCRYPT') && (PROP_LUA_ENCRYPT.compareTo('1') == 0)
    if (compileScript || encryptLua) {
        // -1 means not build bytecode
        // 0 means build 32bit only
        // 1 means build 64bit only
        // 2 means build both 32bit & 64bit
        def buildType = -1
        if (compileScript) {
            def need64 = false
            def need32 = false
            def abis = PROP_APP_ABI.split(':').collect{it as String}
            abis.each{ abi->
                if (abi.compareTo('arm64-v8a') == 0) {
                    need64 = true
                }
                else
                {
                    need32 = true
                }
            }

            if (need64 && need32) {
                buildType = 2
            }
            else if (need64) {
                buildType = 1
            }
            else {
                buildType = 0
            }
        }

        // invoke cocos command to compile & encrypt the lua files
        switch (buildType) {
            case -1:
                compileLua("${buildDir}/intermediates/assets/${variant.dirName}/src",
                           "${buildDir}/intermediates/assets/${variant.dirName}/src",
                           false, false, encryptLua)
                break
            case 0:
                compileLua("${buildDir}/intermediates/assets/${variant.dirName}/src",
                           "${buildDir}/intermediates/assets/${variant.dirName}/src",
                           true, false, encryptLua)
                break
            case 1:
                compileLua("${buildDir}/intermediates/assets/${variant.dirName}/src",
                           "${buildDir}/intermediates/assets/${variant.dirName}/src/64bit",
                           true, true, encryptLua)

                // remove the lua files in src dir
                delete fileTree("${buildDir}/intermediates/assets/${variant.dirName}/src") {
                    include '**/*.lua'
                }
                delete "${buildDir}/intermediates/assets/${variant.dirName}/src/cocos"
                break
            case 2:
                compileLua("${buildDir}/intermediates/assets/${variant.dirName}/src",
                           "${buildDir}/intermediates/assets/${variant.dirName}/src/64bit",
                           true, true, encryptLua)
                compileLua("${buildDir}/intermediates/assets/${variant.dirName}/src",
                           "${buildDir}/intermediates/assets/${variant.dirName}/src",
                           true, false, encryptLua)
                break
        }
    }
}

}

我使用的v4.0 ,build都没问题。我把spine默认是没有加入的,我把spine的编译开关开了后,spine出现错误。

cocos2d-x version: v4.0
devices test on: mac
developing environments
NDK version: r20b
Xcode version: 11.3.1

我搞错了,android sdk需要 sdkmanager.bat --licenses ,之后安装cmake,配置 环境变量,最后还有错误

很多人说 要安装ninja ,我也安装了,环境变量也配置了为什么还是不通过
https://blog.csdn.net/ccw0054/article/details/89916091
这么多坑为什么官方不出来解释一下

放弃v4.0后,用v3.17.2版本,
macOS 10.14.6
Xcode 11.3.1
运行
cocos run -p mac

得到编译错误:
frameworks/cocos2d-x/external/bullet/include/bullet/LinearMath/btVector3.h:330:7: error: argument value 10880 is
outside the valid range [0, 255] [-Wargument-outside-range]
y = bt_splat_ps(y, 0x80);
^~~~~~~~~~~~~~~~~~~~

fix:
#define BT_SHUFFLE(x, y, z, w) (((w) << 6 | (z) << 4 | (y) << 2 | (x)) & 0xff)

解决上面问题。

1赞

我已经放弃4.0 ,3.17.2了 改用3.16

@mobile_app 感谢 出现同样问题解决了 能问下是何原因导致的吗