Gradle Build Failed -试图在Android, Unity 2021.3.18f1上运行HelloCa



请帮助,我是Unity的新手,我一直在遵循Google Cardboard VR的简单教程。

按build后出现4个错误:

1。

CommandWithNoStdoutInvokationFailure: Gradle initialization failed.
UnityEditor.Android.Command.RunWithShellExecute (System.String command, System.String args, System.String workingdir, System.String errorMsg) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
UnityEditor.Android.AndroidJavaTools.RunJavaWithShellExecute (System.String args, System.String workingdir, System.String error) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
UnityEditor.Android.GradleWrapper.WarmupGradle (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingDir, System.String baseCommand) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
Rethrow as GradleInvokationException: Gradle initialization failed.
UnityEditor.Android.GradleWrapper.WarmupGradle (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingDir, System.String baseCommand) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
UnityEditor.Android.PostProcessAndroidPlayer+<>c__DisplayClass5_0.<ExecuteWarmup>b__0 () (at <8b5e5c27dd23466cbbae54c94c729526>:0)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <1f66344f2f89470293d8b67d71308c07>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <1f66344f2f89470293d8b67d71308c07>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <1f66344f2f89470293d8b67d71308c07>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <1f66344f2f89470293d8b67d71308c07>:0)
System.Threading.ThreadHelper.ThreadStart () (at <1f66344f2f89470293d8b67d71308c07>:0)
UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)
  • FAILURE: Build failed with an exception.
    * What went wrong:
    Failed to load native library 'native-platform.dll' for Windows 10 amd64.
    * 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
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    
  • CommandInvokationFailure: Gradle build failed. 
    C:Program FilesJavajdk1.8.0_251binjava.exe -classpath "C:Program FilesUnityHubEditor2021.3.18f1EditorDataPlaybackEnginesAndroidPlayerToolsgradlelibgradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    Environment Variables:
    USERDOMAIN = DESKTOP-J02I1QO
    ProgramFiles = C:Program Files
    TMP = C:UsersUserAppDataLocalTemp
    PROCESSOR_ARCHITECTURE = AMD64
    PROCESSOR_REVISION = 7e05
    OneDriveConsumer = C:UsersUserOneDrive
    OS = Windows_NT
    CHROME_CRASHPAD_PIPE_NAME = \.pipecrashpad_11092_BQAOBDZMUBKRBXVC
    PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 126 Stepping 5, GenuineIntel
    ProgramW6432 = C:Program Files
    USERPROFILE = C:UsersUser
    JAVA_HOME = C:Program FilesJavajdk1.8.0_251
    CommonProgramFiles = C:Program FilesCommon Files
    DriverData = C:WindowsSystem32DriversDriverData
    ComSpec = C:WINDOWSsystem32cmd.exe
    PSModulePath = C:Program FilesWindowsPowerShellModules;C:WINDOWSsystem32WindowsPowerShellv1.0Modules
    PUBLIC = C:UsersPublic
    USERNAME = User
    NUMBER_OF_PROCESSORS = 4
    GIT = C:UsersUserDownloadsGit-2.39.2-64-bit.exe
    JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
    FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
    TEMP = C:UsersUserAppDataLocalTemp
    Path = C:Program FilesMicrosoftjdk-11.0.12.7-hotspotbin;C:Program Files (x86)Common FilesOracleJavajavapath;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program Filesdotnet;C:Program FilesGitcmd;C:UsersUserAppDataLocalProgramsPythonPython39Scripts;C:UsersUserAppDataLocalProgramsPythonPython39;C:UsersUserAppDataLocalProgramsPythonPython38-32Scripts;C:UsersUserAppDataLocalProgramsPythonPython38-32;C:UsersUserAppDataLocalMicrosoftWindowsApps;C:UsersUser.dotnettools
    COMPUTERNAME = DESKTOP-J02I1QO
    PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    ALLUSERSPROFILE = C:ProgramData
    SystemDrive = C:
    windir = C:WINDOWS
    FPS_BROWSER_USER_PROFILE_STRING = Default
    ZES_ENABLE_SYSMAN = 1
    CommonProgramFiles(x86) = C:Program Files (x86)Common Files
    APPDATA = C:UsersUserAppDataRoaming
    OneDrive = C:UsersUserOneDrive
    PROCESSOR_LEVEL = 6
    CommonProgramW6432 = C:Program FilesCommon Files
    ProgramFiles(x86) = C:Program Files (x86)
    SystemRoot = C:WINDOWS
    SESSIONNAME = Console
    LOGONSERVER = \DESKTOP-J02I1QO
    LOCALAPPDATA = C:UsersUserAppDataLocal
    HOMEPATH = UsersUser
    HOMEDRIVE = C:
    USERDOMAIN_ROAMINGPROFILE = DESKTOP-J02I1QO
    ProgramData = C:ProgramData
    ORIGINAL_XDG_CURRENT_DESKTOP = undefined
    
    stderr[
    FAILURE: Build failed with an exception.
    * What went wrong:
    Failed to load native library 'native-platform.dll' for Windows 10 amd64.
    * 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
    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 <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <8b5e5c27dd23466cbbae54c94c729526>: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 <8b5e5c27dd23466cbbae54c94c729526>: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 <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8b5e5c27dd23466cbbae54c94c729526>: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 <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <8b5e5c27dd23466cbbae54c94c729526>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <8b5e5c27dd23466cbbae54c94c729526>: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 <42a64fd733d9417da1ea3a757ad9a96d>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    
    4
  • UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <42a64fd733d9417da1ea3a757ad9a96d>:0 
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <42a64fd733d9417da1ea3a757ad9a96d>:0 
    UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    

    外部工具页:

    我使用Android Studio和Gradle 6.9.4,启用了"自定义Gradle属性模板";和"自定义Gradle主模板";就像在Unity的Google Cardboard快速入门。

    我尝试使用Android Studio的jdk和Android的默认Unity jdk和Java的jdk-20(不兼容,目前使用jdk-18)。还找到了Windows 10和Windows 64的"native-platform.dll"。gradle>gradle-6.9.4>lib中的JAR文件,但我不确定我能用它做什么。请告诉我还需要什么信息。

    不如降级Unity版本?我以前遇到过这个问题,我把Unity降级到2020.3.41f1。或者你可以尝试youtube链接中提供的步骤:https://www.youtube.com/watch?v=Jldd2CE37Xo&t=165s这对我很有效。希望它对你也有帮助。

    最新更新