Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Gradle Build Failed

Discussion in 'Android' started by YURI_uwu, Aug 25, 2020.

  1. YURI_uwu

    YURI_uwu

    Joined:
    Mar 12, 2019
    Posts:
    12
    Unity version: 2019.4.8f1
    Platform: Android
    Scripting Backend: IL2CPP
    API Compatibility level: .NET 4.X
    Target Architectures: ARMv7 and ARM64

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

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

    FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring project ':launcher'.
    > android.defaultConfig.versionCode is set to 0, but it should be a positive integer.
    See https://developer.android.com/studio/publish/versioning#appversioning for more information.

    * 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 11s
    ]
    stdout[
    Starting a Gradle Daemon, 1 stopped 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 <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <d265dd4439034d6c9926c590736e62a5>: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 <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d265dd4439034d6c9926c590736e62a5>: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 <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <d265dd4439034d6c9926c590736e62a5>: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 <d265dd4439034d6c9926c590736e62a5>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <d265dd4439034d6c9926c590736e62a5>: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/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:340)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr) (at /Users/builduser/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:197)
     
  2. YURI_uwu

    YURI_uwu

    Joined:
    Mar 12, 2019
    Posts:
    12
    Ok just woke up this morning and just read the build error message in the console, it seems that the problem was with the build# in the player settings which is set to 0. SET YOUR BUILD# TO ANY POSITIVE INTEGER. THAT'S IT!
     
    swayanshu2003 likes this.
  3. bigbrainz

    bigbrainz

    Joined:
    Jul 21, 2015
    Posts:
    177
    AHA. This was just the post I needed. Thank you!

    BTW, for me specifically it was changing the `Bundle Version Code` in "Other Settings" to something other than zero that allowed it to build for me. I've been making Android builds for years with this just set at zero, so I'm not sure why all of a sudden it got mad at me.