androidandroid-studioflutter

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


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

Solution

  • 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:

    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.