Unity Gradle 构建失败::launcher

问题描述 投票:0回答:1
CommandInvokationFailure: Gradle build failed. 
C:\Program Files\Unity\Hub\Editor\2021.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

Environment Variables:
KMP_DUPLICATE_LIB_OK = TRUE
CUDA_CACHE_MAXSIZE = 268435456
ProgramFiles = C:\Program Files
TMP = C:\Users\devau\AppData\Local\Temp
NVVFX_MODEL_DIR = C:\Program Files\NVIDIA Corporation\NVIDIA Video Effects\models
PROCESSOR_ARCHITECTURE = AMD64
BAZEL_SH = c:\msys64\usr\bin\bash.exe
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_12536_WDEHADUWIWVDKREW
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 141 Stepping 1, GenuineIntel
VRAY_MDL_PATH_3DSMAX2023 = C:\Program Files\Chaos Group\V-Ray\3ds Max 2023\mdl
ProgramW6432 = C:\Program Files
PROCESSOR_REVISION = 8d01
USERPROFILE = C:\Users\devau
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2021.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
INTEL_DEV_REDIST = C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
USERDOMAIN = LAPTOP-9HLG01UH
PUBLIC = C:\Users\Public
SystemRoot = C:\Windows
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
NUMBER_OF_PROCESSORS = 16
ZES_ENABLE_SYSMAN = 1
MIC_LD_LIBRARY_PATH = C:\Program Files (x86)\Common Files\Intel\Shared Libraries\compiler\lib\mic
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
ADSK_3DSMAX_x64_2023 = C:\Program Files\Autodesk\3ds Max 2023\
ADSK_3DSMAX_x64_2020 = C:\Program Files\Autodesk\3ds Max 2020\
TEMP = C:\Users\devau\AppData\Local\Temp
Path = C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Common Files\Autodesk Shared\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Users\devau\AppData\Local\Microsoft\WindowsApps;C:\Users\devau\AppData\Roaming\npm;C:\Users\devau\AppData\Local\Programs\Microsoft VS Code\bin;C:\adb;C:\Program Files\Common Files\Autodesk Shared\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Python27;C:\Users\devau\AppData\Local\Microsoft\WindowsApps;C:\Users\devau\AppData\Roaming\npm;C:\Users\devau\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\devau\AppData\Local\Programs\Python\Python310\Scripts;C:\tmp;C:\msys64\usr\bin;C:\nuget;C:\Users\devau\AppData\Roaming\Python\Python310\site-packages\virtualenv;C:\Users\devau\AppData\Local\Programs\MiKTeX\miktex\bin\x64\
VRAY_FOR_3DSMAX2023_MAIN = C:\ProgramData\Autodesk\ApplicationPlugins\VRay3dsMax2023/bin
USERNAME = devau
COMPUTERNAME = LAPTOP-9HLG01UH
VRAY_FOR_3DSMAX2023_PLUGINS = C:\ProgramData\Autodesk\ApplicationPlugins\VRay3dsMax2023/bin/plugins
VRAY_OSL_PATH_3DSMAX2023 = C:\ProgramData\Autodesk\ApplicationPlugins\VRay3dsMax2023\opensl
ALLUSERSPROFILE = C:\ProgramData
SystemDrive = C:
windir = C:\Windows
HOMEDRIVE = C:
VRAY_SEND_FEEDBACK = 0
HOMEPATH = \Users\devau
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\devau\AppData\Roaming
OneDrive = C:\Users\devau\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
NVIDIAWHITELISTED = 0x01
SESSIONNAME = Console
LOGONSERVER = \\LAPTOP-9HLG01UH
LOCALAPPDATA = C:\Users\devau\AppData\Local
PT8HOME = C:\Program Files\Cisco Packet Tracer 8.1.1
SHIM_MCCOMPAT = 0x810000001
USERDOMAIN_ROAMINGPROFILE = LAPTOP-9HLG01UH
ProgramData = C:\ProgramData


stderr[

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':launcher'.
> Could not resolve all artifacts for configuration ':launcher:classpath'.
   > Could not find com.android.tools.build:gradle:6.1.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
       - https://jcenter.bintray.com/com/android/tools/build/gradle/6.1.1/gradle-6.1.1.pom
     Required by:
         project :launcher

* 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

BUILD FAILED in 1s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <53a24fd937e24f249a40af7ff60927ab>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <53a24fd937e24f249a40af7ff60927ab>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <53a24fd937e24f249a40af7ff60927ab>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <6e08e61cfda04255b3972ba7f0515fae>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

规格:

  • 团结 2021.3.20f1

我尝试了各种修复

  • 按照Unity的推荐下载Gradle 6.1.1并在preferences中设置
  • 下载 JDK 8 并在首选项中设置它
  • 尝试导出到 Android Studio 并构建,但它显示以下错误 “不支持的 Java。 您的构建当前配置为使用 Java 17.0.6 和 Gradle 6.1.1.

可能的解决方案:

  • 将 Gradle wrapper 升级到 7.2 版本并重新导入项目”

没有任何工作,所有 Gradle Build 失败都不是这种类型或没有得到回答。请帮助我从早上 5 小时起就一直在努力解决这个问题,我什至没有吃早餐!

java unity3d gradle android-gradle-plugin gvr-android-sdk
1个回答
0
投票

你混淆了 gradle 和 android gradle 插件,检查这个链接:https://docs.unity3d.com/2023.2/Documentation/Manual/android-gradle-overview.html

build.gradle文件中,需要配置的是android gradle plugin,对应的版本是4.0.1.

classpath 'com.android.tools.build:gradle:4.0.1'

顺便说一下gradle路径是在Unity的preferences里面设置的

© www.soinside.com 2019 - 2024. All rights reserved.