CocosCreator 安卓出包错误记录

环境配置
Android Studio 3.6.2
Windows 10 10.0
Memory: 4062M
Cocos Creator 2.4.3

  1. 先创建原始工程,然后保证能够成功跑起来。
    这时 打开File-->Project Structure-->Project 记录这时的Gradle对应版本,这个是在你本地能够正常运行的版本。
    image.png

错误1

[armeabi-v7a] Compile++ arm  : cocos2dx_static <= CCTTFTypes.cpp
I:/xxx/jsb-default/frameworks/cocos2d-x/cocos/2d/CCTTFLabelAtlasCache.cpp:74:9: error: use of undeclared identifier 'assert'
        assert(FileUtils::getInstance()->isFileExist(_fontName));
        ^
1 error generated.
make: *** [I:/xxx/jsb-default/frameworks/runtime-src/proj.android-studio/app/build/intermediates/ndkBuild/release/obj/local/armeabi-v7a/objs/cocos2dx_static/2d/CCTTFLabelAtlasCache.o] Error 1
make: *** Waiting for unfinished jobs....

> Task :dev:externalNativeBuildRelease FAILED

FAILURE: Build failed with an exception.

我这边发现原因应该是NDK版本的问题。
我的版本是 android-ndk-r14b,
当我的版本更新为 android-ndk-r21d。
就OK了。

错误2


> Task :dev:transformNativeLibsWithStripDebugSymbolForRelease
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip: warning: I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\arm64-v8a\libsecsdk.so has a corrupt string table index - ignoring
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip: error: the input file 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\arm64-v8a\libsecsdk.so' has no sections

Unable to strip library '1' due to error D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-strip returned from 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\arm64-v8a\libsecsdk.so', packaging it as is.
Unable to strip library 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi\libEncryptorP.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi\libgism.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi\libsecsdk.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi\libturingad.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
Unable to strip library 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi\libWXSign.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip: warning: I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi-v7a\libsecsdk.so has a corrupt string table index - ignoring
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip: error: the input file 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi-v7a\libsecsdk.so' has no sections

Unable to strip library '1' due to error D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-strip returned from 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\armeabi-v7a\libsecsdk.so', packaging it as is.
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86-4.9\prebuilt\windows-x86_64\bin\i686-linux-android-strip: warning: I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86\libsecsdk.so has a corrupt string table index - ignoring
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86-4.9\prebuilt\windows-x86_64\bin\i686-linux-android-strip: error: the input file 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86\libsecsdk.so' has no sections

Unable to strip library '1' due to error D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86-4.9\prebuilt\windows-x86_64\bin\i686-linux-android-strip returned from 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86\libsecsdk.so', packaging it as is.
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86_64-4.9\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip: warning: I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86_64\libsecsdk.so has a corrupt string table index - ignoring
D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86_64-4.9\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip: error: the input file 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86_64\libsecsdk.so' has no sections

Unable to strip library '1' due to error D:\1_develop_tools\Android\android-ndk-r21d-windows-x86_64\android-ndk-r21d\toolchains\x86_64-4.9\prebuilt\windows-x86_64\bin\x86_64-linux-android-strip returned from 'I:\xxx\jsb-default\frameworks\runtime-src\play800-dgz\app\build\intermediates\transforms\mergeJniLibs\release\0\lib\x86_64\libsecsdk.so', packaging it as is.

> Task :dev:checkReleaseLibraries
> Task :dev:processReleaseJavaRes NO-SOURCE
> Task :dev:transformResourcesWithMergeJavaResForRelease
> Task :dev:validateSigningRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dev:validateSigningRelease'.
> Keystore file 'D:\androidstudio\mtool\swzg.keystore' not found for signing config 'release'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

注意最后面,问题是没有找到签名文件。
找到,或是创建对应的签名文件即可。

错误3

> Task :dev:packageRelease
> Task :dev:packageRelease FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dev:packageRelease'.
> I:\xxx\jsb-default\frameworks\runtime-src\Play800-dgz\app\build\intermediates\merged_assets\release\mergeReleaseAssets\out\assets\fightRes\import\10\10036efa-e022-4778-9b50-2a2358cd873a.json (ϵͳ�Ҳ���ָ����·����)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.6.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 3m 6s
67 actionable tasks: 13 executed, 54 up-to-date
15:33:26: Task execution finished 'assembleRelease'.

问题显示貌似是某个json 的资源文件有问题。
重新构建了一次资源,再次打包就ok了

错误4

> Task :dev:createDebugCompatibleScreenManifests UP-TO-DATE

> Task :dev:processDebugManifest FAILED
I:\xxx\jsb-default\frameworks\runtime-src\Play800-dgz\app\AndroidManifest.xml:24:9-41 Error:
    Attribute application@label value=(@string/app_name) from AndroidManifest.xml:24:9-41
    is also present at [test.aar] AndroidManifest.xml:20:18-49 value=(ocpc_action_sdk).
    Suggestion: add 'tools:replace="android:label"' to  element at AndroidManifest.xml:21:5-52:19 to override.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dev:processDebugManifest'.
> Manifest merger failed : Attribute application@label value=(@string/app_name) from AndroidManifest.xml:24:9-41
    is also present at [test.aar] AndroidManifest.xml:20:18-49 value=(ocpc_action_sdk).
    Suggestion: add 'tools:replace="android:label"' to  element at AndroidManifest.xml:21:5-52:19 to override.

描述就是说,这个android:label="@string/app_name"标签,在[test.aar]已经存在定义了。建议我们按描述替换。
就是加上 xmlns:tools="http://schemas.android.com/tools" tools:replace="android:label"这俩
替换后的样子就成了


就OK了。

错误5

2021-01-20 16:14:38.636 11640-11713/com.test D/jswrapper: JS: ======> loadBundle  internal
2021-01-20 16:14:38.641 11640-11713/com.test D/jswrapper: JS: ======> loadBundle  resources
2021-01-20 16:14:39.079 11640-11713/com.test E/jswrapper: ScriptEngine::evalString catch exception:
2021-01-20 16:14:39.152 11640-11713/com.test E/jswrapper: ERROR: Uncaught ReferenceError: sp is not defined, location: assets/main/index.js:0:0
    STACK:
    [0]window.__require.ResourceId@assets/main/index.js:53876
    [1]s@assets/main/index.js:18
    [2]e@assets/main/index.js:26
    [3]anonymous@assets/main/index.js:28
    [4]anonymous@jsb-adapter/jsb-engine.js:2316
    [5]download@jsb-adapter/jsb-engine.js:2327
    [6]downloadScript@jsb-adapter/jsb-engine.js:2315
    [7]anonymous@jsb-adapter/jsb-engine.js:2483
    [8]anonymous@jsb-adapter/jsb-engine.js:2156
    [9]readFile@jsb-adapter/jsb-engine.js:2122
    [10]readJson@jsb-adapter/jsb-engine.js:2144
    [11]parseJson@jsb-adapter/jsb-engine.js:2441
    [12]download@jsb-adapter/jsb-engine.js:2327
    [13]downloadJson@jsb-adapter/jsb-engine.js:2453
    [14]downloadBundle@jsb-adapter/jsb-engine.js:2475
    [15]invoke@src/cocos2d-jsb.js:11609
    [16]process@src/cocos2d-jsb.js:11619
    [17]retry@src/cocos2d-jsb.js:13206
    [18]download@src/cocos2d-jsb.js:11643
    [19]load@src/cocos2d-jsb.js:12317
2021-01-20 16:14:39.152 11640-11713/com.test D/debug info: Uncaught Exception:
     - location :  (see stack)
     - msg : Uncaught ReferenceError: sp is not defined
     - detail : 
          [0]window.__require.ResourceId@assets/main/index.js:53876
    [1]s@assets/main/index.js:18
    [2]e@assets/main/index.js:26
    [3]anonymous@assets/main/index.js:28
    [4]anonymous@jsb-adapter/jsb-engine.js:2316
    [5]download@jsb-adapter/jsb-engine.js:2327
    [6]downloadScript@jsb-adapter/jsb-engine.js:2315
    [7]anonymous@jsb-adapter/jsb-engine.js:2483
    [8]anonymous@jsb-adapter/jsb-engine.js:2156
    [9]readFile@jsb-adapter/jsb-engine.js:2122
    [10]readJson@jsb-adapter/jsb-engine.js:2144
    [11]parseJson@jsb-adapter/jsb-engine.js:2441
    [12]download@jsb-adapter/jsb-engine.js:2327
    [13]downloadJson@jsb-adapter/jsb-engine.js:2453
    [14]downloadBundle@jsb-adapter/jsb-engine.js:2475
    [15]invoke@src/cocos2d-jsb.js:11609
    [16]process@src/cocos2d-jsb.js:11619
    [17]retry@src/cocos2d-jsb.js:13206
    [18]download@src/cocos2d-jsb.js:11643
    [19]load@src/cocos2d-jsb.js:12317
2021-01-20 16:14:39.152 11640-11713/com.test D/jswrapper: JS: [ERROR]: (see stack) Uncaught ReferenceError: sp is not defined [0]window.__require.ResourceId@assets/main/index.js:53876
    [1]s@assets/main/index.js:18
    [2]e@assets/main/index.js:26
    [3]anonymous@assets/main/index.js:28
    [4]anonymous@jsb-adapter/jsb-engine.js:2316
    [5]download@jsb-adapter/jsb-engine.js:2327
    [6]downloadScript@jsb-adapter/jsb-engine.js:2315
    [7]anonymous@jsb-adapter/jsb-engine.js:2483
    [8]anonymous@jsb-adapter/jsb-engine.js:2156
    [9]readFile@jsb-adapter/jsb-engine.js:2122
    [10]readJson@jsb-adapter/jsb-engine.js:2144
    [11]parseJson@jsb-adapter/jsb-engine.js:2441
    [12]download@jsb-adapter/jsb-engine.js:2327
    [13]downloadJson@jsb-adapter/jsb-engine.js:2453
    [14]downloadBundle@jsb-adapter/jsb-engine.js:2475
    [15]invoke@src/cocos2d-jsb.js:11609
    [16]process@src/cocos2d-jsb.js:11619
    [17]retry@src/cocos2d-jsb.js:13206
    [18]download@src/cocos2d-jsb.js:11643
    [19]load@src/cocos2d-jsb.js:12317
2021-01-20 16:14:39.152 11640-11713/com.test E/jswrapper: ScriptEngine::evalString script assets/main/index.js, failed!
2021-01-20 16:14:39.152 11640-11713/com.test E/jswrapper: [ERROR] Failed to invoke require, location: I:/DGZ-A/client/branches/develop/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/manual/jsb_global.cpp:300
2021-01-20 16:14:39.177 11640-11713/com.test D/renderer:  (616): Device caps: maxVextexTextures: 16, maxFragUniforms: 1024, maxTextureUints: 16, maxVertexAttributes: 16, maxDrawBuffers: 1, maxColorAttatchments: 1
2021-01-20 16:14:39.196 11640-11713/com.test E/jswrapper: ScriptEngine::onGetStringFromFile ./assemblers/motion-streak.js not found, possible missing file.
2021-01-20 16:14:39.196 11640-11713/com.test E/jswrapper: ScriptEngine::runScript script ./assemblers/motion-streak.js, buffer is empty!

问题是,在js层报错,sp不存在。 也就是Spine。
但是在我的creator 项目设置里,spine是有勾选的。

image.png

最后发现,还是因为引擎在编译时,未将spine 模块的代码编译到so。
因为, Application.mk 文件 定义 USE_SPINE 值为0,将这个定义值改为1 就好了

# application.mk
USE_GFX_RENDERER := 1
USE_VIDEO := 0
USE_WEB_VIEW := 0
USE_AUDIO := 1
USE_SOCKET := 1
USE_SPINE := 1
USE_DRAGONBONES := 0
USE_TIFF := 1
USE_MIDDLEWARE := 1
USE_PARTICLE := 1

这里定义这cpp 代码中的相关模块的宏定义
因为我本身的工程有调整,所以生成的mk文件,不是默认生成的工程里的。
所以导致这些宏定义未正常修改。

错误6

修改了C++ 引擎源码, 在Android Studio构建时,debug没问题,C++源码有重新编译,但是release时,C++源码死都不重新编译,导致最后的so一直没有更新。
解决办法是,将安卓工程的构建目录 删了, 重新打开工程,构建就哦了。


image.png

PS

调试安卓原生平台
传送门

你可能感兴趣的:(CocosCreator 安卓出包错误记录)