Unity error: Exception: Gradle install not valid
Unity error: Exception: Gradle install not valid
我在 Unity 上制作了一个简单的基于文本的 Android 应用程序。当我尝试构建它来制作应用程序包时,出现了以下错误。如果有熟悉这些错误的人,你能给我一些解决问题的建议吗?
错误 1
异常:Gradle 安装无效
UnityEditor.Android.GradleWrapper.GetBaseCommand(System.Int32 jvmHeapSize)(在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.PostProcessAndroidPlayer.ExecuteWarmup(System.String 暂存区)(位于 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess(UnityEditor.BuildTarget 目标,System.String stagingAreaData,System.String stagingArea,System.String playerPackage,System.String installPath,System.String 公司名称,System.String 产品名称,UnityEditor.BuildOptions 选项,UnityEditor.RuntimeClassRegistry usedClassRegistry,UnityEditor.Build.Reporting.BuildReport 报告)(在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32宽度,System.Int32 高度,UnityEditor.BuildOptions 选项,UnityEditor.RuntimeClassRegistry usedClassRegistry,UnityEditor.Build.Reporting.BuildReport 报告)(在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
错误2
构建完成,结果为 'Failed'
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
错误3
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 个错误
在 UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer(UnityEditor.BuildPlayerOptions 选项)[0x00242] 在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190
在 UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] 在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
"Details of the errors"
当 Unity 在应用程序构建过程中处理以下这 3 个部分时,总是会出现错误。
1,Hidden/VideoDecode - Flip_NV12_To_RGB1:剥离顶点程序
2, Hidden/Compositing -Mix_RGBA_To_RGBA: 剥离顶点程序
3,Hidden/VideoDecodeAndroid - RGBASplitExternal_To_RGBA:剥离顶点...
"About Unity platform"
我的Unity版本:2019.2.9f1和2019.2.13f1(遇到错误我更新了)
我用的Android SDK(28.0.3),NDK(android-ndk-r16b) 和openJDK(1.8.0_152)都是原来安装的Unity 版本。
"Gradle install with Unity(recomemded)" 项已经检查过。
我在第一次构建项目时选择了LWRP模板。
我遇到了类似的问题。
对我来说,来自 https://answers.unity.com/questions/1534863/gradle-install-not-valid.html 的答案有效:
if you go to editor>Preferences External Tools tab there is a check
box for Gradle Install with Unity. Make sure this check box is checked
检查您的 gradle 路径。它应该是包含 lib/gradle-launcher-*.jar
的文件夹
就我而言,它只是将 UnityEditor 设置中的 gradle 路径从 /usr/local/Cellar/gradle/6.7.1
更改为 /usr/local/Cellar/gradle/6.7.1/libexec
UnityEditor 错误应该更详细地说明此类错误配置。
// UnityEditor.Android.GradleWrapper
internal static string GetBaseCommand(int jvmHeapSize)
{
string gradleLaunchJarPath = AndroidGradleRoot.GetGradleLaunchJarPath(AndroidGradleRoot.GetInstance().GetRootDirectory());
bool flag = string.IsNullOrEmpty(gradleLaunchJarPath);
if (flag)
{
throw new Exception("Gradle install not valid");
}
return string.Format("-classpath \"{0}\" org.gradle.launcher.GradleMain \"-Dorg.gradle.jvmargs=-Xmx{1}m\"", gradleLaunchJarPath, jvmHeapSize);
}
// UnityEditor.Android.AndroidGradleRoot
internal static string GetGradleLaunchJarPath(string directory)
{
string path = Paths.Combine(new string[]
{
directory,
"lib"
});
string[] array = AndroidFileLocator.Find(Path.Combine(path, "gradle-launcher-*.jar"));
bool flag = array.Length == 1;
string result;
if (flag)
{
result = array[0];
}
else
{
result = null;
}
return result;
}
我在 Unity 上制作了一个简单的基于文本的 Android 应用程序。当我尝试构建它来制作应用程序包时,出现了以下错误。如果有熟悉这些错误的人,你能给我一些解决问题的建议吗?
错误 1
异常:Gradle 安装无效 UnityEditor.Android.GradleWrapper.GetBaseCommand(System.Int32 jvmHeapSize)(在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.PostProcessAndroidPlayer.ExecuteWarmup(System.String 暂存区)(位于 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess(UnityEditor.BuildTarget 目标,System.String stagingAreaData,System.String stagingArea,System.String playerPackage,System.String installPath,System.String 公司名称,System.String 产品名称,UnityEditor.BuildOptions 选项,UnityEditor.RuntimeClassRegistry usedClassRegistry,UnityEditor.Build.Reporting.BuildReport 报告)(在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (在 <13e769c2760a442eaf6dff80696716f1>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32宽度,System.Int32 高度,UnityEditor.BuildOptions 选项,UnityEditor.RuntimeClassRegistry usedClassRegistry,UnityEditor.Build.Reporting.BuildReport 报告)(在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
错误2
构建完成,结果为 'Failed' UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
错误3
UnityEditor.BuildPlayerWindow+BuildMethodException: 2 个错误 在 UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer(UnityEditor.BuildPlayerOptions 选项)[0x00242] 在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:190 在 UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] 在 /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindowBuildMethods.cs:95 UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)(在 /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)
"Details of the errors"
当 Unity 在应用程序构建过程中处理以下这 3 个部分时,总是会出现错误。
1,Hidden/VideoDecode - Flip_NV12_To_RGB1:剥离顶点程序
2, Hidden/Compositing -Mix_RGBA_To_RGBA: 剥离顶点程序
3,Hidden/VideoDecodeAndroid - RGBASplitExternal_To_RGBA:剥离顶点...
"About Unity platform"
我的Unity版本:2019.2.9f1和2019.2.13f1(遇到错误我更新了)
我用的Android SDK(28.0.3),NDK(android-ndk-r16b) 和openJDK(1.8.0_152)都是原来安装的Unity 版本。
"Gradle install with Unity(recomemded)" 项已经检查过。
我在第一次构建项目时选择了LWRP模板。
我遇到了类似的问题。
对我来说,来自 https://answers.unity.com/questions/1534863/gradle-install-not-valid.html 的答案有效:
if you go to editor>Preferences External Tools tab there is a check box for Gradle Install with Unity. Make sure this check box is checked
检查您的 gradle 路径。它应该是包含 lib/gradle-launcher-*.jar
就我而言,它只是将 UnityEditor 设置中的 gradle 路径从 /usr/local/Cellar/gradle/6.7.1
更改为 /usr/local/Cellar/gradle/6.7.1/libexec
UnityEditor 错误应该更详细地说明此类错误配置。
// UnityEditor.Android.GradleWrapper
internal static string GetBaseCommand(int jvmHeapSize)
{
string gradleLaunchJarPath = AndroidGradleRoot.GetGradleLaunchJarPath(AndroidGradleRoot.GetInstance().GetRootDirectory());
bool flag = string.IsNullOrEmpty(gradleLaunchJarPath);
if (flag)
{
throw new Exception("Gradle install not valid");
}
return string.Format("-classpath \"{0}\" org.gradle.launcher.GradleMain \"-Dorg.gradle.jvmargs=-Xmx{1}m\"", gradleLaunchJarPath, jvmHeapSize);
}
// UnityEditor.Android.AndroidGradleRoot
internal static string GetGradleLaunchJarPath(string directory)
{
string path = Paths.Combine(new string[]
{
directory,
"lib"
});
string[] array = AndroidFileLocator.Find(Path.Combine(path, "gradle-launcher-*.jar"));
bool flag = array.Length == 1;
string result;
if (flag)
{
result = array[0];
}
else
{
result = null;
}
return result;
}