You need to enable JavaScript to run this app. Unity 2020 Android打包时Gradle构建编译失败的问题求助
优惠活动
大模型
产品
解决方案
定价
更多

Unity 2020 Android打包时Gradle构建编译失败的问题求助

Unity 2020 编译Android Release版本异常说明

基础环境

  • 开发引擎:Unity 2020
  • 运行配套:JDK 1.8.0_281、Gradle 7.0
  • 触发场景:执行Android Release打包任务assembleRelease

异常信息分类

1. launcher模块配置警告

> Configure project :launcher
WARNING: The option 'android.enableR8' is deprecated and should not be used anymore.
It will be removed in a future version of the Android Gradle plugin, and will no longer allow you to disable R8.

警告说明:该提示为警告级别,不直接阻断构建流程。android.enableR8配置项已废弃,后续Android Gradle插件版本会移除该参数,届时无法通过该配置禁用R8。

2. 构建流程阻断报错

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
FAILURE: Build failed with an exception.
* What went wrong:
 Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Failed to query the value of task ':unityLibrary:compileReleaseJavaWithJavac' property 'options.generatedSourceOutputDirectory'.
> Querying the mapped value of map(java.io.File property(org.gradle.api.file.Directory, property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, H:\FinalPluginProjectTest\Temp\gradleOut\unityLibrary\build\generated\ap_generated_sources\release\out))) org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@545c8bb4) before task ':unityLibrary:compileReleaseJavaWithJavac' has completed is not supported

报错说明:核心错误为unityLibrary模块的Release版本Java编译任务执行失败,系统不支持在该任务完全执行完成前,查询其生成源码输出目录的映射属性值。

3. 底层命令执行日志

CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Java\jdk1.8.0_281\bin\java.exe -classpath "H:\gradle-7.0\lib\gradle-launcher-7.0.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Failed to query the value of task ':unityLibrary:compileReleaseJavaWithJavac' property 'options.generatedSourceOutputDirectory'.
> Querying the mapped value of map(java.io.File property(org.gradle.api.file.Directory, property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, H:\FinalPluginProjectTest\Temp\gradleOut\unityLibrary\build\generated\ap_generated_sources\release\out))) org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@545c8bb4) before task ':unityLibrary:compileReleaseJavaWithJavac' has completed is not supported

求助需求

  • 请有相关经验的开发者协助定位上述异常的根因
  • 如需补充其他排查相关信息可随时沟通

内容的提问来源于stack exchange,提问作者Hope1_

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.22 14:24:07