CommandInvokationFailure:Gradle 构建失败。统一

时间:2021-04-29 07:30:08

标签: java c# android unity3d gradle

我正在尝试为 android 构建我的 Unity 游戏,但我遇到了这个问题,请帮助我该怎么做。我是 unity 的初学者,没有太多经验。

错误信息如下:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Cannot create service of type TaskExecuter using ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #22 of type ReservedFileSystemLocationRegistry.
> Cannot create service of type ReservedFileSystemLocationRegistry using ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List<ReservedFileSystemLocation>.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Cannot create service of type TaskExecuter using ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #22 of type ReservedFileSystemLocationRegistry.
> Cannot create service of type ReservedFileSystemLocationRegistry using ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List<ReservedFileSystemLocation>.

* 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 4m 6s

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


CommandInvokationFailure: Gradle build failed. 
/Applications/Unity/Hub/Editor/2020.3.5f1/PlaybackEngines/AndroidPlayer/OpenJDK/bin/java -classpath "/Applications/Unity/Hub/Editor/2020.3.5f1/PlaybackEngines/AndroidPlayer/Tools/gradle/lib/gradle-launcher-5.6.4.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

stderr[
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Cannot create service of type TaskExecuter using ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #22 of type ReservedFileSystemLocationRegistry.
> Cannot create service of type ReservedFileSystemLocationRegistry using ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List<ReservedFileSystemLocation>.

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Cannot create service of type TaskExecuter using ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #22 of type ReservedFileSystemLocationRegistry.
> Cannot create service of type ReservedFileSystemLocationRegistry using ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List<ReservedFileSystemLocation>.

* 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 4m 6s
]
stdout[

]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>: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 <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <2c6e9a95f1dd4e06ad71afcd2684dcb7>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, 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 /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:337)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


Build completed with a result of 'Failed' in 297 seconds (296813 ms)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)


UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002be] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in /Users/bokken/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95 
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:189)

我不知道如何解决这个问题。请帮忙。 :(

当我用同样的问题搜索其他答案时,他们都给出了关闭广告或类似问题的解决方案,但我的游戏中根本没有任何广告。

PS:我使用 Photon PUN 是为了多人游戏。

1 个答案:

答案 0 :(得分:2)

如果您直接在外部驱动器上构建,这是一个常见问题。尝试直接在您的硬盘上构建。