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

sy5wg1nm  于 2023-08-06  发布在  Android
关注(0)|答案(1)|浏览(145)

请帮助,我是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,启用了“自定义Gradle属性模板”和“自定义主Gradle模板”,就像在Google Cardboard Quickstart for Unity中一样。
我尝试使用Android Studio的JDK和Android的默认Unity JDK以及Java的JDK-20(不兼容,目前使用JDK-18)。还在gradle>gradle-6.9.4>lib中找到了“'native-platform.dll' for Windows 10 amd 64“JAR文件,但我不确定我能用它做什么。请让我知道需要什么其他信息。

jv4diomz

jv4diomz1#

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

相关问题