title: How to fix ''Gradle Build Failed'' on Unity?
body: <p>I'm trying to build my android app for a while and can't seem to find any solution for this problem:
  <a href="https://i.stack.imgur.com/TgLkX.png" rel="nofollow noreferrer">Image</a></p>
  <p>Unity Version: Unity 2020.3.21f1 (64-bit)
  JDK, SDK, NDK and Gradle used are Unity's recommended ones (already tried to use other ones).</p>
  <p>The console details are here:</p>
  <pre><code>Configure project :launcher
  WARNING: The option setting 'android.enableR8=false' is deprecated.
  It will be removed in version 5.0 of the Android Gradle plugin.
  You will no longer be able to disable R8
  
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)`
  
      FAILURE: Build failed with an exception.
  
      * What went wrong:
      com/sun/istack/FinalArrayList
      
      * 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.
  
      CommandInvokationFailure: Gradle build failed. 
      C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath &quot;C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar&quot; org.gradle.launcher.GradleMain &quot;-Dorg.gradle.jvmargs=-Xmx4096m&quot; &quot;assembleRelease&quot;
      
      stderr[
      
      FAILURE: Build failed with an exception.
  
      Build completed with a result of 'Failed' in 60 seconds (59527 ms)
      UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in &lt;208f92fc783546f9abbe643bfc23920c&gt;:0 
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in &lt;208f92fc783546f9abbe643bfc23920c&gt;:0 
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  </code></pre>
  <p>I already tried all tutorials on youtube and other forums, but every help is welcome, thanks!</p>
  <p>Edit 1:</p>
  <p>After trying Jaimin's solution this is happening now:</p>
  <pre><code>Assets/Plugins/Android\gradleTemplate.properties file is using a deprecated way of controlling which tool should be used to do the minification. To fix this, remove &quot;useProguard&quot; entries yourself. If not fixed, your build can fail.
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  
   File C:\Users\Windows\.android\repositories.cfg could not be loaded.
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
  
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  com/sun/istack/FinalArrayList
  &gt; com.sun.istack.FinalArrayList
  
  * 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 5s
  Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
  
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  CommandInvokationFailure: Gradle build failed. 
  C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath &quot;C:\Program Files\Unity\Hub\Editor\2020.3.21f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar&quot; org.gradle.launcher.GradleMain &quot;-Dorg.gradle.jvmargs=-Xmx4096m&quot; &quot;assembleRelease&quot;
  
  stderr[
  
  FAILURE: Build failed with an exception.
  
  * What went wrong:
  com/sun/istack/FinalArrayList
  &gt; com.sun.istack.FinalArrayList
  
  * 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 5s
  Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
  ]
  stdout[
  Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
  ]
  exit code: 1
  UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;: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 &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;: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 &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;: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 &lt;f94168442e634613b6a5965ed17c38f4&gt;:0)
  UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties&amp; outProperties) (at &lt;f94168442e634613b6a5965ed17c38f4&gt;: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 &lt;208f92fc783546f9abbe643bfc23920c&gt;:0)
  UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&amp;)
  
  Build completed with a result of 'Failed' in 127 seconds (127448 ms)
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  
  UnityEditor.BuildPlayerWindow+BuildMethodException: 5 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002ca] in &lt;208f92fc783546f9abbe643bfc23920c&gt;:0 
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in &lt;208f92fc783546f9abbe643bfc23920c&gt;:0 
  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&amp;)
  </code></pre>
  <p>And here's how the Custom Gradle Properties Template file is coded:</p>
  <pre><code>org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
  org.gradle.parallel=true
  unityStreamingAssets=.unity3d**STREAMING_ASSETS**
  **ADDITIONAL_PROPERTIES**
  </code></pre>