How to fix "Execution failed for task ':app:processDebugResources'. > Android resource linking failed"[Android/Flutter]

Viewed 29960

It happened out of nowhere. One day I was running my code which was working just fine, and the next day, without touching my build.gradle files or any other build files this error popped up.

I have tried a lot of different solutions like changing my buildToolsVersion or setting a specific flag of AAPT(can't remember which) to false. Nothing works. My app\build.gradle file:

 android {
 compileSdkVersion 27
 buildToolsVersion '27.0.3'

 sourceSets {
     main.java.srcDirs += 'src/main/kotlin'
 } 

 lintOptions {
     disable 'InvalidPackage'
 }

 defaultConfig {
     // TODO: Specify your own unique Application ID 
     (https://developer.android.com/studio/build/application-id.html).
     applicationId "com.skydevs.bookx"
     minSdkVersion 16
     targetSdkVersion 27
     versionCode flutterVersionCode.toInteger()
     versionName flutterVersionName
     testInstrumentationRunner 
     "android.support.test.runner.AndroidJUnitRunner"
 }

 buildTypes {
     release {
         // TODO: Add your own signing config for the release build.
         // Signing with the debug keys for now, so `flutter run --release` 
         works.
         signingConfig signingConfigs.debug
     }
 }
 }

 flutter {
     source '../..'
 }

 dependencies {
   implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'com.android.support.test:runner:1.0.2'
   androidTestImplementation 'com.android.support.test.espresso:espresso- 
   core:3.0.2'
   implementation 'com.google.firebase:firebase-core:16.0.1'
 }

 apply plugin: 'com.google.gms.google-services'

The error I'm getting is:

Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
  Output:  C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
  C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
  C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:905: error: resource android:attr/fontVariationSettings not found.
  C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:905: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

  Command: C:\Users\baada\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a5cc63922d025d4315a498efa486650c\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          C:\Users\baada\AppData\Local\Android\sdk\platforms\android-27\android.jar\
          --manifest\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
          -o\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
          -R\
          @C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
          --auto-add-overlay\
          --java\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
          --custom-package\
          com.example.bookx\
          -0\
          apk\
          --output-text-symbols\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\symbols\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
  Output:  C:\Users\baada\.gradle\caches\transforms-1\files-1.1\appcompat-1.0.2.aar\aa44270b14856bd5a0b17a3c0a45cb34\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.

  C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.

  C:\Users\baada\.gradle\caches\transforms-1\files-1.1\core-1.0.1.aar\bc8b94f938baa5558925fd51b49cb6bf\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/fontVariationSettings not found.

  C:\Users\baada\.gradle\caches\transforms-1\files-1.1\core-1.0.1.aar\bc8b94f938baa5558925fd51b49cb6bf\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/ttcIndex not found.

  error: failed linking references.
  Command: C:\Users\baada\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a5cc63922d025d4315a498efa486650c\aapt2-3.2.1-4818971-windows\aapt2.exe link -I\
          C:\Users\baada\AppData\Local\Android\sdk\platforms\android-27\android.jar\
          --manifest\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
          -o\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
          -R\
          @C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
          --auto-add-overlay\
          --java\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
          --custom-package\
          com.example.bookx\
          -0\
          apk\
          --output-text-symbols\
          C:\Users\baada\AndroidStudioProjects\bookx\build\app\intermediates\symbols\debug\R.txt\
          --no-version-vectors
  Daemon:  AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
7 Answers

Today, I got the same error at my project which I was working on yesterday without any problem.

Some upgrade causes this error IMO, my solution is:

  • Open the project via Android Studio

  • Open android/build.gradle and android/app/build.gradle

  • Just correct things what IDE warns about, it usually warns your SDK, Kotlin and Gradle versions etc.

It's not mandatory but you can check your .bashrc exports or environment variables, sometimes it can fix some problems.

Edit: When you are updating your SDK versions, don't forget to upgrade also your project dependencies.

I think it depends on android emulator API level you are using.

In my case I used android emulator API 30, but compileSdkVersion was 28, so i got the error! By updating compileSdkVersion to 30, everything worked correctly!

OS: Ubuntu 20.04 LTS
Android emulator API 30
Dart 2.10.2
Flutter 1.22.2

Kindly check your strings.xml and It should be like:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">App Name here</string>
    <string name="facebook_app_id">2206883509627625</string>
    <string name="fb_login_protocol_scheme">fb2206883509627625</string>
</resources>

Special attention to add this line:

    <string name="app_name">App Name here</string>

I had the same error while using flutter, but in my case the problem was caused by an incorrect line in a file in the 'res' folder in my Adroid projects.

You need to check your code, in my case it was calling a resource that doesn't exist in my android / app / src / main / res / launcher / drawable / launch_background.xml file, make sure all your resources and xml files are ok.

check that How to fix "Execution failed for task ':app:processDebugResources'. > Android resource linking failed"[Android/Flutter]

I had the same error while using flutter, but in my case the problem was caused by an incorrect line in a file in the 'res' folder in my Adroid projects.

You need to check your code, in my case it was calling a resource that doesn't exist in my android / app / src / main / res / launcher / drawable / launch_background.xml file, make sure all your resources and xml files are ok.

To resolve this issue, run your flutter project in Android Studio rather than Visual Studio Code.

Make sure you are connected to the Internet and rebuild the project. That solves the problem for me.

Related