cocos creator 打安卓包构建成功,编译失败

已经按照官网教程试过两遍了,困扰了很久,

日志内容:
编译模式:debug
使用 Android Studio 工程:D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio
正在生成 apk 文件…
正在执行:’“D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradlew.bat” --parallel --info assembleDebug’

Initialized native services in: C:\Users\Administrator\.gradle\native
The client will now receive all logging from the daemon (pid: 14468). The daemon log file: C:\Users\Administrator\.gradle\daemon\4.10.3\daemon-14468.out.log
Starting 2nd build in daemon [uptime: 7 mins 52.704 secs, performance: 95%, no major garbage collections]
Using 8 worker leases.
Invalidating in-memory cache of D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\.gradle\4.10.3\fileHashes\fileHashes.bin
Starting Build
Settings evaluated using settings file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\settings.gradle'.
Projects loaded. Root project using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\build.gradle'.
Included projects: [root project 'proj.android-studio', project ':code', project ':game', project ':instantapp', project ':libcocos2dx']
Parallel execution is an incubating feature.

> Configure project :
Evaluating root project 'proj.android-studio' using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\build.gradle'.

> Configure project :code
Evaluating project ':code' using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle'.
Creating configuration androidTestUtil
Creating configuration compile
Creating configuration apk
Creating configuration provided
Creating configuration api
Creating configuration implementation
Creating configuration runtimeOnly
Creating configuration compileOnly
Creating configuration wearApp
Creating configuration annotationProcessor
Creating configuration androidTestCompile
Creating configuration androidTestApk
Creating configuration androidTestProvided
Creating configuration androidTestApi
Creating configuration androidTestImplementation
Creating configuration androidTestRuntimeOnly
Creating configuration androidTestCompileOnly
Creating configuration androidTestWearApp
Creating configuration androidTestAnnotationProcessor
Creating configuration testCompile
Creating configuration testApk
Creating configuration testProvided
Creating configuration testApi
Creating configuration testImplementation
Creating configuration testRuntimeOnly
Creating configuration testCompileOnly
Creating configuration testWearApp
Creating configuration testAnnotationProcessor
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to C:\Users\Administrator\AppData\Local\Android\Sdk\ndk.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.

Creating configuration debugCompile
Creating configuration debugApk
Creating configuration debugProvided
Creating configuration debugApi
Creating configuration debugImplementation
Creating configuration debugRuntimeOnly
Creating configuration debugCompileOnly
Creating configuration debugWearApp
Creating configuration debugAnnotationProcessor
Creating configuration androidTestDebugCompile
Creating configuration androidTestDebugApk
Creating configuration androidTestDebugProvided
Creating configuration androidTestDebugApi
Creating configuration androidTestDebugImplementation
Creating configuration androidTestDebugRuntimeOnly
Creating configuration androidTestDebugCompileOnly
Creating configuration androidTestDebugWearApp
Creating configuration androidTestDebugAnnotationProcessor
Creating configuration testDebugCompile
Creating configuration testDebugApk
Creating configuration testDebugProvided
Creating configuration testDebugApi
Creating configuration testDebugImplementation
Creating configuration testDebugRuntimeOnly
Creating configuration testDebugCompileOnly
Creating configuration testDebugWearApp
Creating configuration testDebugAnnotationProcessor
Creating configuration releaseCompile
Creating configuration releaseApk
Creating configuration releaseProvided
Creating configuration releaseApi
Creating configuration releaseImplementation
Creating configuration releaseRuntimeOnly
Creating configuration releaseCompileOnly
Creating configuration releaseWearApp
Creating configuration releaseAnnotationProcessor
Creating configuration testReleaseCompile
Creating configuration testReleaseApk
Creating configuration testReleaseProvided
Creating configuration testReleaseApi
Creating configuration testReleaseImplementation
Creating configuration testReleaseRuntimeOnly
Creating configuration testReleaseCompileOnly
Creating configuration testReleaseWearApp
Creating configuration testReleaseAnnotationProcessor
Parsing the SDK, no caching allowed
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation01\unzip\src
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation02\unzip\android-9
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation03\unzip\android-6.0
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation04\unzip\src
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation05\unzip\src
Parsing legacy package: C:\Users\Administrator\AppData\Local\Android\Sdk\.temp\PackageOperation06\unzip\android-8.0.0
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\28.0.2\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\28.0.3\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\29.0.3\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\30.0.0-rc4\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\build-tools\30.0.1\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\cmdline-tools\1.0\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\cmdline-tools\latest\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\emulator\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\extras\intel\Hardware_Accelerated_Execution_Manager\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\ndk\19.2.5345600\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\ndk\21.3.6528147\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\patcher\v4\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\platform-tools\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\platforms\android-27\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\platforms\android-29\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\sources\android-29\package.xml
Parsing C:\Users\Administrator\AppData\Local\Android\Sdk\tools\package.xml
SDK initialized in 154 ms
FAILURE: Build failed with an exception.


* What went wrong:
A problem occurred configuring project ':code'.
> java.lang.NullPointerException (no error message)

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

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

BUILD FAILED in 0s
执行命令出错,返回值:1。

我的配置:
NDK路径 : C:\Users\Administrator\AppData\Local\Android\Sdk\ndk
Android SDK路径 : C:\Users\Administrator\AppData\Local\Android\Sdk

我没有安卓APP基础,不懂什么SDK,NDK什么的,我都按照官网上的步骤一步步去做,但有一些地方跟官网是不太一样,
比方说:

我就没有找到有ndk-bundle 文件夹,但是找到了ndk文件夹,我就把他放上去用了

@jare, @Cocos-Cjie, 实在看不懂了

尝试了一下
https://blog.csdn.net/weixin_42753193/article/details/106132685
这个博客的方式,我改了
code\build\jsb-link\frameworks\runtime-src\proj.android-studio\build.gradle
文件,
将他的

classpath改成3.5.2 还是没什么用…

这是新的日志信息
> Configure project :code
Evaluating project ‘:code’ using build file ‘D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle’.
FAILURE: Build failed with an exception.

* Where:
Build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle' line: 3

* What went wrong:

Compiling build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle' using BuildScriptTransformer.
A problem occurred evaluating project ':code'.
> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 5.4.1. Current version is 4.10.3. If using the gradle wrapper, try editing the distributionUrl in D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip

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

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

BUILD FAILED in 20s
执行命令出错,返回值:1。

Android studio 配置:
首次编译需正确配置sdk ndk 建议 creator版本是2.x以上使用ndk版本r21b。
修改Gradle Scripts下 build.gradle(proj.android-studio文件)将文件中jcenter()注释掉。拷贝 maven{url ‘http://maven.aliyun.com/nexus/content/groups/public/’} 放置google()之上

这是我之前打安卓包总结的。目测是没问题。

你好,我试了一下你的方法

还是不行

编译模式:debug
使用 Android Studio 工程:D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio
正在生成 apk 文件...
正在执行:'"D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradlew.bat" --parallel --info assembleDebug'

Initialized native services in: C:\Users\Administrator\.gradle\native
The client will now receive all logging from the daemon (pid: 2584). The daemon log file: C:\Users\Administrator\.gradle\daemon\4.10.3\daemon-2584.out.log
Starting 3rd build in daemon [uptime: 5 mins 44.498 secs, performance: 100%, no major garbage collections]
Using 8 worker leases.
Starting Build
Settings evaluated using settings file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\settings.gradle'.
Projects loaded. Root project using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\build.gradle'.
Included projects: [root project 'proj.android-studio', project ':code', project ':game', project ':instantapp', project ':libcocos2dx']
Parallel execution is an incubating feature.

> Configure project :
Evaluating root project 'proj.android-studio' using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\build.gradle'.

> Configure project :code
Evaluating project ':code' using build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle'.

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\app\build.gradle' line: 3

* What went wrong:
A problem occurred evaluating project ':code'.
> Failed to apply plugin [id 'com.android.application']
   > Minimum supported Gradle version is 5.4.1. Current version is 4.10.3. If using the gradle wrapper, try editing the distributionUrl in D:\LiJiaJian\Project\changzheng85\code\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip

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

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

BUILD FAILED in 0s
执行命令出错,返回值:1。

这是新的日志,我不知道我哪一步搞错了

我的cocos 版本是 2.3.3
android studio 版本是 3.5.2

大佬,解决了吗?

环境变量添加上去了,打包的进度条多走了一部分,大概80%左右,就又崩了,:grimacing:

这个ndk里面好像还有一个文件,用那个文件试试

我用了

:sob::sob::sob::sob::sob:

迪迦的祝福

宫崎骏的祝福

魔法少女小圆的祝福

https://mp.weixin.qq.com/s/oxa4B5Kd4ArhcgfV9DmsRA

可以对比这个试试看
我重装环境后,都可以的

NDK is missing a “platforms” directory.

世界再见

再把Android Studio 删掉,换成3.0的版本,

删除以上文件

sdk删除

环境变量删除

重新配置环境 action 3

因为后面几次更改,每次报错信息都不一样了:sob: 没办法,再从配一次

尝试中…