Gradle 构建失败 - 尝试在 Android、Unity 2021.3.18f1 上运行 HelloCardboard

问题描述 投票:0回答:1

请帮忙,我是 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 Files\Java\jdk1.8.0_251\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-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:\Users\User\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 7e05
OneDriveConsumer = C:\Users\User\OneDrive
OS = Windows_NT
CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_11092_BQAOBDZMUBKRBXVC
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 126 Stepping 5, GenuineIntel
ProgramW6432 = C:\Program Files
USERPROFILE = C:\Users\User
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_251
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\WINDOWS\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC = C:\Users\Public
USERNAME = User
NUMBER_OF_PROCESSORS = 4
GIT = C:\Users\User\Downloads\Git-2.39.2-64-bit.exe
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
TEMP = C:\Users\User\AppData\Local\Temp
Path = C:\Program Files\Microsoft\jdk-11.0.12.7-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\User\AppData\Local\Programs\Python\Python39\;C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\User\AppData\Local\Programs\Python\Python38-32\;C:\Users\User\AppData\Local\Microsoft\WindowsApps;C:\Users\User\.dotnet\tools
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:\Users\User\AppData\Roaming
OneDrive = C:\Users\User\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\WINDOWS
SESSIONNAME = Console
LOGONSERVER = \\DESKTOP-J02I1QO
LOCALAPPDATA = C:\Users\User\AppData\Local
HOMEPATH = \Users\User
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&)

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&)

The External Tools page:

我使用了 Android Studio 和 Gradle 6.9.4,启用了“Custom Gradle Properties Template”和“Custom Main Gradle Template”,就像在 Google Cardboard Quickstart for Unity 中一样。

我尝试使用 Android Studio 的 jdk 和 Android 的默认 Unity jdk 和 Java 的 jdk-20(不兼容,目前使用 jdk-18)。还在 gradle>gradle-6.9.4>lib 中找到了适用于 Windows 10 amd64 的“'native-platform.dll'”JAR 文件,但我不确定我能用它做什么。请让我知道还需要什么其他信息。

android unity-game-engine gradle google-cardboard unity-editor
1个回答
0
投票

你有没有解决过这个问题,或者你有没有像我一样废弃这个项目

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