新人,打包原生报错

构建成功了,但是编译成android原生时失败

  • Creator 版本:2.4.7

  • 目标平台:Android

  • 重现方式:构成成功,编译失败

  • 报错日志: Building mode: debug
    Using Android Studio project : D:\project-zombie\zombeat\build\jsb-link\frameworks\runtime-src\proj.android-studio
    Building apk…
    running: ‘“D:\project-zombie\zombeat\build\jsb-link\frameworks\runtime-src\proj.android-studio\gradlew.bat” --parallel --info assembleDebug’

Downloading https://services.gradle.org/distributions/gradle-6.7.1-all.zip

Unzipping C:\Users\MYH.gradle\wrapper\dists\gradle-6.7.1-all\1cdfdhmv7jlccg398629lhd1uj\gradle-6.7.1-all.zip to C:\Users\MYH.gradle\wrapper\dists\gradle-6.7.1-all\1cdfdhmv7jlccg398629lhd1uj
Initialized native services in: C:\Users\MYH.gradle\native

Welcome to Gradle 6.7.1!

Here are the highlights of this release:

  • File system watching is ready for production use
  • Declare the version of Java your build requires
  • Java 15 support

For more details see Gradle 6.7.1 Release Notes

Found daemon DaemonInfo{pid=14152, address=[92e03806-d743-4eaa-b5a5-cb4ef007f408 port:62022, addresses:[/127.0.0.1]], state=Idle, lastBusy=1652439442327, context=DefaultDaemonContext[uid=e5980230-4681-4a2c-b955-01a69f701a72,javaHome=D:\Android\jre,daemonRegistryDir=C:\Users\MYH.gradle\daemon,pid=14152,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]} however its context does not match the desired criteria.
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=C:\Program Files\Java\jdk1.8.0_144,daemonRegistryDir=C:\Users\MYH.gradle\daemon,pid=1504,idleTimeout=null,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
Actual: DefaultDaemonContext[uid=e5980230-4681-4a2c-b955-01a69f701a72,javaHome=D:\Android\jre,daemonRegistryDir=C:\Users\MYH.gradle\daemon,pid=14152,idleTimeout=10800000,priority=NORMAL,daemonOpts=-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]

Looking for a different daemon…
Removing 0 daemon stop events from registry
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
Starting process ‘Gradle build daemon’. Working directory: C:\Users\MYH.gradle\daemon\6.7.1 Command: C:\Program Files\Java\jdk1.8.0_144\bin\java.exe -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=GBK -Duser.country=CN -Duser.language=zh -Duser.variant -cp C:\Users\MYH.gradle\wrapper\dists\gradle-6.7.1-all\1cdfdhmv7jlccg398629lhd1uj\gradle-6.7.1\lib\gradle-launcher-6.7.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.7.1
Successfully started process ‘Gradle build daemon’
An attempt to start the daemon took 1.804 secs.
The client will now receive all logging from the daemon (pid: 10388). The daemon log file: C:\Users\MYH.gradle\daemon\6.7.1\daemon-10388.out.log
Starting build in new daemon [memory: 477.6 MB]
Using 12 worker leases.

FAILURE: Build failed with an exception.

  • What went wrong:
    Gradle could not start your build.

Could not create service of type FileHasher using BuildSessionServices.createFileHasher().
Unexpected lock protocol found in lock file. Expected 3, found 0.

  • 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 34s
Error running command, return code: 1.

麻烦大佬一下

JDK版本和 Gradle 版本我感觉都不行

Java版本:


我用的Creator版本是2.4.7,所以Gradle 版本是官方文档中的 6.7.1,哪个版本不对,大佬能说一下吗

构建的android版本这些是多少?

android-28,对应的应该是9.0

看下ndk版本对应不 还是ndk太老了

我也没打出来 成功了告诉我一下版本 同2.4.7

用官方推荐的r17,r19,别人帖子推荐的r21,都试过了,都不行

是直接编译的吗还是用android studio 有错误可以看吗

现在用的是cocos 直接编译的,用android studio导入后好像没办法构建

在android studio执行了Sync Project with Gradle Files后,提示如下


但是我Cocos Creator里NDK配置的路径就是Android studio下载的ndk的路径,环境变量也配置了同样的路径,不知道为什么会检测不到NDK版本

1:as里面clean下 重新编译.
2:尝试将项目里面gradle的缓存文件删除掉后重新让gradle构建工程.
3:看错误日志像是一些文件的权限问题.需要检查下系统是不是管理员权限.

官方的默认构建工程一般是没有问题的. 我每次测试官方的版本更新都是直接导出as工程,默认都能打出包,没有任何红色错误.

把.gradle文件夹里的caches文件夹删除了就可以了,谢谢大佬。但是奇怪的是我早上尝试过把整个.gradle文件都删了却不行

这次还把项目的build文件夹删除了,不知道和这个有没有关系,好得有点奇怪,以后有空再测看看

看下这个能不能解决@ nlh1996

可能是打包路径太深了

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。