Search Unity

  1. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

Gradle build failed

Discussion in 'Android' started by luoyu510183, Mar 20, 2019.

  1. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    37
    thank you man!!! we try and later send the results!!!!
     
  2. shashkes

    shashkes

    Joined:
    Mar 16, 2017
    Posts:
    19
    I was getting this error and turns out the names of my folders were too long.

     
  3. amityadav9898ay

    amityadav9898ay

    Joined:
    Nov 3, 2019
    Posts:
    1
    There are few way to solve gradle build

    1. change from system build from gradle to internal
    2. You can resolve gradle by going C:\Users\(user name path)\.gradle and delete this .gradle file build again and make sure you are connected to internet.
    3. sometime it also occur because of minimum API level of sdk so try to change them to Android 4.4 or 5.0
    for full detail visit https://www.unity3d.co.in/2020/08/how-to-fix-android-gradle-build-failed.html
     
    Last edited: Aug 15, 2020
    cultzone likes this.
  4. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    80
    problem fixed here :
     
    Last edited: Jun 5, 2021
  5. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    37
    make changes on the java versions... it most common problem...
     
    Last edited: Jan 13, 2021
  6. Rodolfomachado

    Rodolfomachado

    Joined:
    Apr 15, 2020
    Posts:
    2
    ---------------------------------------------------------------------------------------------------------------------------------------------


    An important point is the name of your project, is there are different points or letters , may cause a misfunction during the gradle out, to solve this is renaming your project, even in the windows explorer , to a name which has not these points/letters.
     
  7. Humansquirrel

    Humansquirrel

    Joined:
    Sep 11, 2017
    Posts:
    1
    clear Gradle cache
    it will work
    C:\Users\XXX\gradle\caches
     
  8. dh7300

    dh7300

    Joined:
    Jan 23, 2020
    Posts:
    8
    CommandInvokationFailure: Gradle build failed.

    C:/Program Files/Unity/Hub/Editor/2019.4.12f1/Editor/Data/PlaybackEngines/AndroidPlayer\OpenJDK\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2019.4.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"


    stderr[

    Note: D:\Unity_Project\OMG_Mobile_1016avpro\Temp\gradleOut\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.


    FAILURE: Build failed with an exception.


    * What went wrong:

    Execution failed for task ':launcher:processDebugResources'.

    > Android resource linking failed

    D:\Unity_Project\OMG_Mobile_1016avpro\Temp\gradleOut\launcher\build\intermediates\merged_manifests\debug\AndroidManifest.xml:122: AAPT: error: resource style/Theme.AppCompat.NoActionBar (aka com.vva.android.ventax:style/Theme.AppCompat.NoActionBar) not found.


    error: failed processing manifest.


    * 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

    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.4.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only

    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.4.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only

    Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.4.12f1\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\2019.4.12f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only


    > Task :launcher:preBuild UP-TO-DATE

    > Task :unityLibrary:preBuild UP-TO-DATE

    > Task :unityLibrary:preDebugBuild UP-TO-DATE

    > Task :unityLibrary:checkDebugManifest UP-TO-DATE

    > Task :launcher:extractProguardFiles

    > Task :launcher:prepareLintJar UP-TO-DATE

    > Task :unityLibrary:processDebugManifest

    > Task :unityLibrary:compileDebugAidl NO-SOURCE

    > Task :unityLibrary:packageDebugRenderscript NO-SOURCE

    > Task :unityLibrary:compileDebugRenderscript NO-SOURCE

    > Task :unityLibrary:generateDebugBuildConfig UP-TO-DATE

    > Task :unityLibrary:generateDebugResValues UP-TO-DATE

    > Task :unityLibrary:generateDebugResources UP-TO-DATE

    > Task :unityLibrary:packageDebugResources UP-TO-DATE

    > Task :launcher:preDebugBuild

    > Task :launcher:compileDebugAidl NO-SOURCE

    > Task :launcher:compileDebugRenderscript NO-SOURCE

    > Task :launcher:checkDebugManifest UP-TO-DATE

    > Task :launcher:generateDebugBuildConfig UP-TO-DATE

    > Task :launcher:generateDebugSources UP-TO-DATE

    > Task :launcher:mainApkListPersistenceDebug UP-TO-DATE

    > Task :launcher:generateDebugResValues UP-TO-DATE

    > Task :launcher:generateDebugResources UP-TO-DATE

    > Task :unityLibrary:generateDebugRFile

    > Task :unityLibrary:prepareLintJar UP-TO-DATE

    > Task :unityLibrary:generateDebugSources UP-TO-DATE

    > Task :unityLibrary:javaPreCompileDebug


    > Task :unityLibrary:compileDebugJavaWithJavac


    > Task :unityLibrary:bundleLibCompileDebug UP-TO-DATE

    > Task :unityLibrary:mergeDebugShaders UP-TO-DATE

    > Task :unityLibrary:compileDebugShaders UP-TO-DATE

    > Task :unityLibrary:generateDebugAssets UP-TO-DATE

    > Task :launcher:mergeDebugResources

    > Task :launcher:javaPreCompileDebug UP-TO-DATE

    > Task :launcher:createDebugCompatibleScreenManifests UP-TO-DATE

    > Task :launcher:processDebugManifest

    > Task :unityLibrary:packageDebugAssets

    > Task :unityLibrary:processDebugJavaRes NO-SOURCE

    > Task :unityLibrary:bundleLibResDebug UP-TO-DATE

    > Task :unityLibrary:bundleLibRuntimeDebug

    > Task :unityLibrary:mergeDebugConsumerProguardFiles

    > Task :launcher:processDebugResources FAILED

    > Task :unityLibrary:mergeDebugJniLibFolders


    Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.

    Use '--warning-mode all' to show the individual deprecation warnings.

    See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

    29 actionable tasks: 13 executed, 16 up-to-date

    ]

    exit code: 1

    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <102ea0a8f6844066abf6a495b9136b2c>: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 <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <102ea0a8f6844066abf6a495b9136b2c>: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 <102ea0a8f6844066abf6a495b9136b2c>:0)

    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <102ea0a8f6844066abf6a495b9136b2c>: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 <e6e2fa0a47414cd2ac33237924761b45>:0)

    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    -----------------------------------------------------------------------
    I need help..
     
  9. GameHourStudio

    GameHourStudio

    Joined:
    Apr 17, 2020
    Posts:
    105
    In my case I forgot to save the scene after modifying and was building player so it was giving worker thread error at final step of building player. I saved the scene and then built player and it was fine. This may also be the case for someone so it may also be tried.
     
  10. jfforero

    jfforero

    Joined:
    Dec 6, 2018
    Posts:
    1
    I just changed the name of the folder and its works for me!
     
  11. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    141
    @saqlainniazi63 Which version are you using? upload_2021-2-15_17-49-44.png

    Also check Preferences. This is my settings.
    upload_2021-2-15_17-52-24.png
     
  12. Celso-Formiga

    Celso-Formiga

    Joined:
    Sep 4, 2018
    Posts:
    1
    A simple solution is just to check if the title of the game has special characters. This alone has solved my problem, which was exactly what you are talking about.
     

    Attached Files:

  13. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    80
    Problem fixed here :
     
    Last edited: May 17, 2021
  14. longlsts

    longlsts

    Joined:
    Jun 9, 2021
    Posts:
    1
    But how about the 30.0 (the latest version?)
     
  15. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    141
    Nowaday you just install Unity with Unity Hub.
    They will automatic install everything for you.
     
  16. naxs

    naxs

    Joined:
    May 14, 2021
    Posts:
    3
    here is the solution. The video is in Russian
     
  17. richardgalfi2006

    richardgalfi2006

    Joined:
    Apr 21, 2021
    Posts:
    1
    longbowgr reply that made my friend fix the issue, do not ever use non-ascii characters in the project, it will fail and produce these issues.
     
  18. FlashGameStudio

    FlashGameStudio

    Joined:
    Jun 1, 2020
    Posts:
    1
    I'm using version 2020.3.14f1 and I solved the problem as follows:

    1 - After configuring KeyStore I try to build an APK. This will generate the Gradle Build Failed error. But it will also create a folder called gradleOut in ProjectName\Temp\gradleOut

    2 - After that I go to ProjectName\Temp\gradleOut\unityLibrary\libs and remove the files support-annotations-24.0.0.jar, support-v4-24.0.0.aar, appcompat-v7-23.1.1.aar and the googlemobileads file -unity.aar

    3 - Edit the ProjectName\Temp\gradleOut\unityLibrary\build.gradle file and remove the following implementations:
    implementation(name: 'appcompat-v7-23.1.1', ext:'aar')
    implementation(name: 'googlemobiles-unity', ext:'aar')
    implementation(name: 'support-v4-24.0.0', ext:'aar')

    4 - And finally I run the following command by CMD inside the gradleOut folder:
    PathTo\OpenJDK\bin\java.exe -classpath "PathTo\gradle-launcher-6.8.3.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    This will generate the project apk inside the ProjectName\Temp\gradleOut\launcher\build\outputs\apk\release data folder called launcher-release.apk

    OBS: If duplication errors occur when running the command this could be due to some library with duplicated methods, for example using GoogleAds and Unity.Ads. I advise in this case to remove GoogleAds


    Hugs from Brazil
     
  19. aravinda1879

    aravinda1879

    Joined:
    Feb 2, 2020
    Posts:
    3
    For me the issue was a mismatch in signing key. Adding alias for key using keystore manager in player settings worked.
     
unityunity