Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Gradle build failed

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

Thread Status:
Not open for further replies.
  1. cultzone

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    39
    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. ahmedaniss

    ahmedaniss

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

    cultzone

    Joined:
    Oct 20, 2019
    Posts:
    39
    make changes on the java versions... it most common problem...
     
    Last edited: Jan 13, 2021
  5. 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.
     
  6. Humansquirrel

    Humansquirrel

    Joined:
    Sep 11, 2017
    Posts:
    1
    clear Gradle cache
    it will work
    C:\Users\XXX\gradle\caches
     
    Farshidbd, UGUR_AMIR and CarvalhoLO like this.
  7. dh7300

    dh7300

    Joined:
    Jan 23, 2020
    Posts:
    9
    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..
     
  8. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    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.
     
  9. jfforero

    jfforero

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

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    150
    @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
     
  11. 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:

    Seb-Academii likes this.
  12. ahmedaniss

    ahmedaniss

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

    longlsts

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

    StartStart

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

    naxs

    Joined:
    May 14, 2021
    Posts:
    3
    here is the solution. The video is in Russian
     
  16. 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.
     
  17. FlashGameStudio

    FlashGameStudio

    Joined:
    Jun 1, 2020
    Posts:
    3
    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
     
  18. 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.
     
  19. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Problem Fixed here :
     
    zebazt11 likes this.
  20. buraakd

    buraakd

    Joined:
    Aug 5, 2021
    Posts:
    3
    If you provide more information about your problem, I might be able to help. What does the console print? What are you trying to do?
     
  21. Fanakartal

    Fanakartal

    Joined:
    Apr 2, 2013
    Posts:
    3
    I had same error on my PC.

    I have installed SDK and NDK tools from Android Studio. I was having the "Build-tool 31.0.0 is missing DX at G:\android-sdk\build-tools\31.0.0\dx.bat" error. Here is how I could solve the problem.

    1- I have installed Android Build Support and OpenJDK from Unity Hub.
    2- I have tried different things in SDK and NDK end. At last, I have installed the latest SDK (31.0.0) and latest neccessary NDK (19.0.5232133 -which is an obsolete version at Android Studio but Unity 2020.3.15f2 requires it).
    3- The error continued. So I have seen in the SDK folder of Android that there are no "dx.bat" file but only "d9.bat" file. So I have changed the name of it to dx.bat and also the jar file in the \lib folder (d9.jar) to "dx.jar". Voila, I had an APK build after that.

    In the player settings, the target Android version is selected as Android 9.0 Pie (API Level 28) by the way. That version also was installed at my Android Studio SDK settings, too.

    I hope it helps those who had an error with custom builds for Unity version 2020.3.15f2 LTS.
     
    MADiFold likes this.
  22. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Last edited: May 24, 2022
  23. NehaTiwari

    NehaTiwari

    Joined:
    Aug 27, 2018
    Posts:
    2
    Hi
    If anyone is still looking for the answer, then follow this document of google -https://developers.google.com/ar/develop/unity/android-11-build
     
    metalpulp and DryreL like this.
  24. DryreL

    DryreL

    Joined:
    Feb 23, 2020
    Posts:
    49
    Same problem here.

    upload_2021-10-4_18-34-6.png
     
  25. unity_49CE9B3CFD716565DED9

    unity_49CE9B3CFD716565DED9

    Joined:
    Oct 10, 2021
    Posts:
    1
    I don't know if you found the solution already,solved this error by doing the following:
    • Export the Project instead of letting Unity build the apk for me (Select "Export Project" in Build Settings)
    • Opened the exported project in Android Studio
    • Changed the build.gradle file to use the 29.0.0-rc1 build tools
     
  26. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    what if I don't have android studio installed at all?
    is that an issue?

    in the unity preferences build-tools folder I see only a folder called 30.0.2
    unity version 2020.3.20f1
     
  27. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    solution for unity version 2020.3.20f1
    i went to Preferences> External tools, and ticked the item called Gradle. it was turned off for me. this allows unity to do it automatically.
     
  28. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,810
    Do you use latest Unity 2019?


    Check this please - https://stackoverflow.com/questions...ected-element-queries-found-in-manifest-error
     
  29. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
  30. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,810
    I guess you need to find a plugin which has/generates manifest with queries
     
  31. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Thanks, I found the culprit, will pass on to the developer of that asset
     
  32. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    problem fixed here :
     
  33. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Problem fixed here :
     
  34. goheh68

    goheh68

    Joined:
    Oct 23, 2021
    Posts:
    1
    Thanks for shareing this info.
     
  35. atulvi

    atulvi

    Joined:
    Oct 28, 2020
    Posts:
    35
    For Target API Level 30:

    Step 01 : Install GoogleMobileAds plugin and setup and Asset > External Dependency Manager > Android Resolver > resolve. [Optional]

    Step 02 : Set Target API Level 30 in Player Setting.




    Step 03 : Tick in Custom Main Gradle Template and Custom Launcher Gradle Template.



    Step 04: How mainTemplate and launcherTemplate files generating. [If not view then first build ignore the errors]



    Step 05 : Added below code into mainTemplate.gradle file with your favorite editor.

    buildscript {
    repositories {
    google()
    mavenCentral()
    }
    dependencies {
    // Must be Android Gradle Plugin 3.6.0 or later. For a list of
    // compatible Gradle versions refer to:
    // https://developer.android.com/studio/releases/gradle-plugin
    classpath 'com.android.tools.build:gradle:3.6.0'
    }
    }

    allprojects {
    repositories {
    google()
    mavenCentral()
    flatDir {
    dirs 'libs'
    }
    }
    }

    //Look like that

    Step 06 : Download Gradle gradle-5.6.4-all.zip from grdale.org. Download from https://services.gradle.org/distributions/

    After download extract the file and set gradle path into Edit > Preference > External Tools > Gradle Install with Unity(recommended) UnChecked



    Step 07 : Build

    Helpful Link : https://developers.google.com/ar/develop/unity-arf/android-11-build
     
  36. yanyuling

    yanyuling

    Joined:
    Jun 14, 2016
    Posts:
    1
    my window unity version is 2020.3.23f1c1 LTS,build android apk success with gradle; gradle plugin 4.0.1, gradle version3.1.1;
    my mac unity version is same version, but build apk failed, i export android studio project check gradle version is 6.8;

    here is my mac build apk error
     

    Attached Files:

  37. waelarafa11

    waelarafa11

    Joined:
    May 3, 2020
    Posts:
    3
    i've changed apply plugin: 'com.android.library' into apply plugin: 'com.android.application' in the build.gradle inside AppPath\Temp\gradleOut\unityLibrary
     
  38. apnpgc1

    apnpgc1

    Joined:
    Dec 20, 2021
    Posts:
    1
  39. VResearch

    VResearch

    Joined:
    Jan 6, 2021
    Posts:
    18
    What if I need them?
     
  40. StartStart

    StartStart

    Joined:
    Jan 2, 2013
    Posts:
    150
    Manual download it is fine too.
     
  41. ryan70aph

    ryan70aph

    Joined:
    Feb 3, 2022
    Posts:
    1
    This thread was really helpful.
     
  42. domportera

    domportera

    Joined:
    Sep 12, 2013
    Posts:
    23
    Well, something very stupid is what fixed it for me.

    Apparently, it didn't like the fact that I had a VPN running in the background (Nord VPN), even though I had split tunneling enabled so only a select few apps were actually routing through it (supposedly).

    So, definitely try that first thing. Easiest solve.
     
  43. wanorde23

    wanorde23

    Joined:
    Jan 31, 2019
    Posts:
    10
    This comment is pretty much the best tip for me I just started deleting all custom packages in my project until I found it was the googleVR plugin that caused the problem for me
     
  44. buraakd

    buraakd

    Joined:
    Aug 5, 2021
    Posts:
    3
    I was getting this error and turns out the names of my folders were too long.
     
    Last edited by a moderator: Feb 23, 2022
  45. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
  46. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
  47. Hashim-J

    Hashim-J

    Joined:
    Aug 10, 2021
    Posts:
    3
    Solved... Plus I was having three more errors and have consulted countless videos, unity forums after a lot of suffering I got my build ready to play. Thank GOD it worked, hopefully it will work for you guys to...)).

    Open your project in unity then go to Edit/Project Settings.../Player and then find identification (like in the image)

    Now finally tick that box (Override Default Package Name), go back hit Build and Booooom... Ready to play your APK.

    Well if this does not work for you so don't blame me because I don't even know how this works. Originally I was totally fed up, couldn't find any solution and started doing random changes in project then somehow got the success...)))
    If someone knows what this option does let me knew. Thanks.

    Unity version 2021.3.0f1
     
    Last edited: May 2, 2022
    DryreL likes this.
  48. ahmedaniss

    ahmedaniss

    Joined:
    Sep 18, 2019
    Posts:
    98
    Problem fixed here :
     
  49. Farshidbd

    Farshidbd

    Joined:
    Mar 8, 2020
    Posts:
    1
    I went all the way, finally clear caches answered |:
     
  50. kokih58992

    kokih58992

    Joined:
    Jul 15, 2022
    Posts:
    1
    Your post was really helpful. Just what I needed. Thank you!
     
Thread Status:
Not open for further replies.