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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Gradle Build Failed. Android resource linking failed.

Discussion in 'Android' started by BBlindBandit, Jan 1, 2019.

  1. BBlindBandit

    BBlindBandit

    Joined:
    Oct 30, 2018
    Posts:
    5
    I am getting this error and cant build for android. I was just starting out with unity so im not sure what to do here.

    CommandInvokationFailure: Gradle build failed.
    D:\UNITY\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "D:\UNITY\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    stderr[
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':processReleaseResources'.
    > Android resource linking failed
    Output: error: failed to create directory 'D:\UnityProjects\SecondTest\Temp\gradleOut\build\generated\not_namespaced_r_class_sources\release\processReleaseResources\r\com\bandit\second'.

    Command: C:\Users\Yi?it Ar?soy\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\85bde20e4c473e7728682a274258fd41\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
    D:\Android_SDK\platforms\android-26\android.jar\
    --manifest\
    D:\UnityProjects\SecondTest\Temp\gradleOut\build\intermediates\merged_manifests\release\processReleaseManifest\merged\AndroidManifest.xml\
    -o\
    D:\UnityProjects\SecondTest\Temp\gradleOut\build\intermediates\processed_res\release\processReleaseResources\out\resources-release.ap_\
    -R\
    @D:\UnityProjects\SecondTest\Temp\gradleOut\build\intermediates\incremental\processReleaseResources\resources-list-for-resources-release.ap_.txt\
    --auto-add-overlay\
    --java\
    D:\UnityProjects\SecondTest\Temp\gradleOut\build\generated\not_namespaced_r_class_sources\release\processReleaseResources\r\
    --custom-package\
    com.bandit.second\
    -0\
    apk\
    -0\
    .unity3d\
    -0\
    .ress\
    -0\
    .resource\
    -0\
    .obb\
    --output-text-symbols\
    D:\UnityProjects\SecondTest\Temp\gradleOut\build\intermediates\symbols\release\R.txt\
    --no-version-vectors
    Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #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 5s
    ]
    stdout[
    :checkReleaseClasspath
    :preBuild UP-TO-DATE
    :preReleaseBuild
    :compileReleaseAidl NO-SOURCE
    :compileReleaseRenderscript
    :checkReleaseManifest
    :generateReleaseBuildConfig
    :prepareLintJar
    :mainApkListPersistenceRelease
    :generateReleaseResValues
    :generateReleaseResources
    :mergeReleaseResources
    :createReleaseCompatibleScreenManifests
    :processReleaseManifest
    :splitsDiscoveryTaskRelease
    :processReleaseResources FAILED
    13 actionable tasks: 13 executed
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <e1c3953b4cf040ddb1400046b1c34897>: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 <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <e1c3953b4cf040ddb1400046b1c34897>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    umaradil likes this.
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    That's the actual error. No idea why it happens. It may be because aapt2 doesn't like your username to have Unicode characters (Yi?it Ar?soy), or maybe and anti-virus software interfering.
     
    dylan-hart likes this.
  3. BBlindBandit

    BBlindBandit

    Joined:
    Oct 30, 2018
    Posts:
    5
    Changing the username to something with regular characters has fixed the problem. However, you cant just go ahead and change the name so im gonna write here how to do it, in case someone else encounters the same problem.
    You have to create a new administrator account, login and then change the name. After that you will have to change a registry in; local machine/software/microsoft/windows nt/ current profile/profile list/the one where you see your old username, and change it to whatever name you changed into.
     
    JuliusM likes this.
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    Thank you for the follow-up.

    Unfortunately the actual issue with Unicode paths seem to lie within Gradle/Android build plugin/AAPT2 and not owned by us, so we can't really fix it on our side.
     
  5. ar_0o0o0

    ar_0o0o0

    Joined:
    Oct 6, 2017
    Posts:
    2
    This was my problem too. I solved this problem like this:
    Close the Unity and Android Studio (if you have) then remove the two folders below.

    C: \ Users \ yourusername \ .gradle
    C: \ Users \ yourusername \ .android
     
  6. hassonhamo3

    hassonhamo3

    Joined:
    May 25, 2018
    Posts:
    38
    I have the same problem , it was going great but I had to reinstall my windows , after that this problem appears :


    CommandInvokationFailure: Gradle build failed.
    C:/Program Files/Java/jdk1.8.0_162\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

    stderr[

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':processReleaseResources'.
    > Android resource linking failed
    Output: E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\incremental\mergeReleaseResources\merged.dir\values-v26\values-v26.xml:7: error: resource android:attr/colorError not found.
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\incremental\mergeReleaseResources\merged.dir\values-v26\values-v26.xml:11: error: resource android:attr/colorError not found.
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\incremental\mergeReleaseResources\merged.dir\values-v26\values-v26.xml:15: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
    error: failed linking references.

    Command: C:\Users\Sniper\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\03361384000dfb8ff34fea660f038f21\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
    C:\Users\Sniper\AppData\Local\Android\sdk\platforms\android-25\android.jar\
    --manifest\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\merged_manifests\release\processReleaseManifest\merged\AndroidManifest.xml\
    -o\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\processed_res\release\processReleaseResources\out\resources-release.ap_\
    -R\
    @E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\incremental\processReleaseResources\resources-list-for-resources-release.ap_.txt\
    --auto-add-overlay\
    --java\
    E:\The Lost Princess Maya\Temp\gradleOut\build\generated\not_namespaced_r_class_sources\release\processReleaseResources\r\
    --proguard\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\proguard-rules\release\aapt_rules.txt\
    --custom-package\
    com.M4H.GL\
    -0\
    apk\
    -0\
    .unity3d\
    -0\
    .ress\
    -0\
    .resource\
    -0\
    .obb\
    --output-text-symbols\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\symbols\release\R.txt\
    --no-version-vectors
    Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #0
    Output: C:\Users\Sniper\.gradle\caches\transforms-1\files-1.1\com.android.support.appcompat-v7-26.1.0.aar\0f6db07822cfb7aac28f98d6185ee4d4\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.

    C:\Users\Sniper\.gradle\caches\transforms-1\files-1.1\com.android.support.appcompat-v7-26.1.0.aar\0f6db07822cfb7aac28f98d6185ee4d4\res\values-v26\values-v26.xml:13:5-16:13: AAPT: error: resource android:attr/colorError not found.

    C:\Users\Sniper\.gradle\caches\transforms-1\files-1.1\com.android.support.appcompat-v7-26.1.0.aar\0f6db07822cfb7aac28f98d6185ee4d4\res\values-v26\values-v26.xml:17:5-93: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.

    error: failed linking references.
    Command: C:\Users\Sniper\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\03361384000dfb8ff34fea660f038f21\aapt2-3.2.0-4818971-windows\aapt2.exe link -I\
    C:\Users\Sniper\AppData\Local\Android\sdk\platforms\android-25\android.jar\
    --manifest\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\merged_manifests\release\processReleaseManifest\merged\AndroidManifest.xml\
    -o\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\processed_res\release\processReleaseResources\out\resources-release.ap_\
    -R\
    @E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\incremental\processReleaseResources\resources-list-for-resources-release.ap_.txt\
    --auto-add-overlay\
    --java\
    E:\The Lost Princess Maya\Temp\gradleOut\build\generated\not_namespaced_r_class_sources\release\processReleaseResources\r\
    --proguard\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\proguard-rules\release\aapt_rules.txt\
    --custom-package\
    com.M4H.GL\
    -0\
    apk\
    -0\
    .unity3d\
    -0\
    .ress\
    -0\
    .resource\
    -0\
    .obb\
    --output-text-symbols\
    E:\The Lost Princess Maya\Temp\gradleOut\build\intermediates\symbols\release\R.txt\
    --no-version-vectors
    Daemon: AAPT2 aapt2-3.2.0-4818971-windows Daemon #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 3s
    ]
    stdout[
    WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
    It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
    :checkReleaseClasspath UP-TO-DATE
    :preBuild UP-TO-DATE
    :extractProguardFiles UP-TO-DATE
    :preReleaseBuild UP-TO-DATE
    :compileReleaseAidl NO-SOURCE
    :compileReleaseRenderscript UP-TO-DATE
    :checkReleaseManifest UP-TO-DATE
    :generateReleaseBuildConfig UP-TO-DATE
    :prepareLintJar UP-TO-DATE
    :mainApkListPersistenceRelease UP-TO-DATE
    :generateReleaseResValues UP-TO-DATE
    :generateReleaseResources UP-TO-DATE
    :mergeReleaseResources UP-TO-DATE
    :createReleaseCompatibleScreenManifests UP-TO-DATE
    :processReleaseManifest
    :splitsDiscoveryTaskRelease UP-TO-DATE
    :processReleaseResources FAILED
    14 actionable tasks: 2 executed, 12 up-to-date
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
    UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
     
  7. IndieDevMans

    IndieDevMans

    Joined:
    Oct 22, 2018
    Posts:
    3
    Hey guys! I've had the same problem, but
    I've found how to fix it.
    First of all, I deleted my custom SDK folder (it used for last versions of unity). Then I went to windows panel and click to java and updated it. And done, now everything works great. I have my installed apk in my device. Try this method guys, it must help.Cheers! ;)
     

    Attached Files:

    BrandoRRS likes this.
  8. resolweru

    resolweru

    Joined:
    Apr 1, 2019
    Posts:
    2
    I have the same problem. I have JDK 8. In Android Studio i updated all platforms and tools. In Unity in External tools I have inserted correct path to Android Studio SDK.

    Thank you in advance.
     

    Attached Files:

    LightningIsAwesome likes this.
  9. AsifNaeem

    AsifNaeem

    Joined:
    Apr 12, 2016
    Posts:
    23

    Hello! Which Unity version you are using? I am using Unity 2018.3.0f2 , There is no built in option for SDK.

    upload_2019-7-12_10-10-19.png
     
  10. hafeezAnonymous215

    hafeezAnonymous215

    Joined:
    Nov 29, 2017
    Posts:
    1
    i fixed this problem by this method:
    1. goto Assets/AndroidServicesResolver/Android/ForceResolve
    2. once resolution is done, remove all duplicate aar files.
    3. now build. its working.
     
    joshuapeacock and Brithingr like this.
  11. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    281
    This not fix the problem to me...any help?
     
  12. sandy_m

    sandy_m

    Joined:
    May 23, 2017
    Posts:
    1
    any help tho??
     
  13. BavrWare

    BavrWare

    Joined:
    Jul 9, 2017
    Posts:
    2
    I had a similar error and after a lot of tries I finally found a solution.

    Go into Project Settings -> Other Settings -> Use custom Launcher Template Gradle file

    In this newly generated .launcherTemplate.gradle file in Assets/Plugins/Android/ enter your correct SDK versions. In my case it was:



    apply plugin: 'com.android.application'

    dependencies {
    implementation project(':unityLibrary')
    }

    android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'

    compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
    minSdkVersion 25
    targetSdkVersion 28
    applicationId '**APPLICATIONID**'
    ndk {
    abiFilters **ABIFILTERS**
    }
    versionCode **VERSIONCODE**
    versionName '**VERSIONNAME**'
    }

    aaptOptions {
    noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
    ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }**SIGN**

    lintOptions {
    abortOnError false
    }

    buildTypes {
    debug {
    minifyEnabled **MINIFY_DEBUG**
    useProguard **PROGUARD_DEBUG**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    jniDebuggable true
    }
    release {
    minifyEnabled **MINIFY_RELEASE**
    useProguard **PROGUARD_RELEASE**
    proguardFiles getDefaultProguardFile('proguard-android.txt')**SIGNCONFIG**
    }
    }**PACKAGING_OPTIONS****SPLITS**
    **BUILT_APK_LOCATION**
    bundle {
    language {
    enableSplit = false
    }
    density {
    enableSplit = false
    }
    abi {
    enableSplit = true
    }
    }
    }**SPLITS_VERSION_CODE****LAUNCHER_SOURCE_BUILD_SETUP**



    This depends on your project but after changing this it worked for me!
     
  14. GoldenEagleTech

    GoldenEagleTech

    Joined:
    Jul 28, 2019
    Posts:
    3
    Hello Everyone!

    If you're still going through this problem no matter what Unity version you're using. How I resolved it was by SETTING THE REQUIRED JDK, SDK & NDK in the Editor.

    1- Go to Edit > Preferences > External Tools
    Check the box "JDK installed with Unity (Recommended).
    And the two boxes for SDK and NDK under it.

    2- Open Unity Hub > Installs > Add Module
    Add ALL Android packages.

    I hope this solves it to all of you guys. Good luck :)
     
    landigj likes this.
  15. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    228
    I was getting this error after adding the following line to AndroidManifest.xml:
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    After reading this thread and re-checking the manifest, I realized I had accidentally put that line inside the <application> block -- that line belongs after the <application> block. Now my builds work again :)
     
    Yury-Habets likes this.
  16. asadmubashr

    asadmubashr

    Joined:
    Feb 10, 2021
    Posts:
    29
    Unity just sucks… They don’t know how to handle dependencies in Android…Just pile of errors one by one, if resolved one another is waiting outside the door and it’s a infinite loop. Bullshit when comes to complex applications
     
    Anton-Baton, ozeol and RaghaStudios like this.
  17. H_Ishfaq

    H_Ishfaq

    Joined:
    Jun 25, 2019
    Posts:
    4
    Thanks , This Worked for me . . .