Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Gradle Build Failed...????

Discussion in 'Editor & General Support' started by Fam-T, Jul 12, 2022.

  1. Fam-T

    Fam-T

    Joined:
    Jun 10, 2022
    Posts:
    2
    I have built this app many times on my phone and everything was fine until i added Ad mob. Anyone know what should do the fix?




    CommandInvokationFailure: Gradle build failed. 
    C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:lintVitalRelease'.
    > This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.
    The following AndroidX dependencies are detected: androidx.versionedparcelable:versionedparcelable:1.1.1, androidx.appcompat:appcompat:1.2.0, androidx.swiperefreshlayout:swiperefreshlayout:1.0.0, androidx.exifinterface:exifinterface:1.0.0, androidx.viewpager2:viewpager2:1.0.0, androidx.activity:activity:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.work:work-runtime:2.7.0, androidx.annotation:annotation:1.3.0, androidx.lifecycle:lifecycle-service:2.1.0, androidx.startup:startup-runtime:1.0.0, androidx.room:room-common:2.2.5, androidx.lifecycle:lifecycle-common:2.3.1, androidx.lifecycle:lifecycle-viewmodel:2.1.0, androidx.browser:browser:1.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.recyclerview:recyclerview:1.1.0, androidx.cursoradapter:cursoradapter:1.0.0, androidx.print:print:1.0.0, androidx.lifecycle:lifecycle-runtime:2.3.1, androidx.core:core:1.7.0, androidx.room:room-runtime:2.2.5, androidx.slidingpanelayout:slidingpanelayout:1.0.0, androidx.fragment:fragment:1.1.0, androidx.customview:customview:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.sqlite:sqlite:2.1.0, androidx.annotation:annotation-experimental:1.1.0, androidx.loader:loader:1.0.0, androidx.core:core-ktx:1.7.0, androidx.sqlite:sqlite-framework:2.1.0, androidx.collection:collection:1.1.0, androidx.viewpager:viewpager:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.arch.core:core-common:2.1.0, androidx.multidex:multidex:2.0.1, androidx.savedstate:savedstate:1.0.0, androidx.appcompat:appcompat-resources:1.2.0, androidx.concurrent:concurrent-futures:1.0.0, androidx.lifecycle:lifecycle-livedata:2.1.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.tracing:tracing:1.0.0, androidx.lifecycle:lifecycle-livedata-core:2.1.0, androidx.arch.core:core-runtime:2.1.0, androidx.documentfile:documentfile:1.0.0, androidx.vectordrawable:vectordrawable-animated:1.1.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.vectordrawable:vectordrawable:1.1.0, androidx.transition:transition:1.2.0

    * 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 2s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[

    > 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
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\30.0.2\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-29\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-30\package.xml. Probably the SDK is read-only
    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2021.3.4f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <c3a2c42a45424b88b29dfadf7f497cbb>: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 <c3a2c42a45424b88b29dfadf7f497cbb>: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 <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <c3a2c42a45424b88b29dfadf7f497cbb>: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 <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <c3a2c42a45424b88b29dfadf7f497cbb>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <c3a2c42a45424b88b29dfadf7f497cbb>: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 <36f62d8e760b48f7af5d32916f997ce1>:0)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    31,318
    Android build not building:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If it does NOT build, then go fix your Unity installation, or your other tools, such as Android SDK, NDK, JDK, etc.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for that subsystem.
     
  3. vagelis199

    vagelis199

    Joined:
    Jul 27, 2012
    Posts:
    138
    I have the same issue with one of my projects. have you figured out anything?
     
  4. vagelis199

    vagelis199

    Joined:
    Jul 27, 2012
    Posts:
    138
    I think this should be moved to Android since its android a related issue.
    Here is what I did and managed to build. (So I guess a solution?)
    Go to player settings and remove graphic API OpenGL ES 2 (if its enabled since its deprecated)
    Then I went to project settings unity mediation and enabled Build Settings. Force future builds to include.... (the last option). Then build.