如何修复“任务#39;:app:processDebugResources#39;执行失败”。gt; Android资源链接失败” [Android / Flutter]

今天,我在项目中遇到了与昨天工作时相同的错误,没有任何问题

某些升级导致此错误IMO,我的解决方案是:

  • 通过Android Studio打开项目

  • 打开android/build.gradleandroid/app/build.gradle

  • 只需纠正IDE警告的内容,它通常会警告您的SDK,Kotlin和Gradle版本等

它不是强制性的,但您可以检查.bashrc导出或环境变量,有时它可以解决一些问题

编辑:更新SDK版本时,请不要忘记也升级项目依赖项

它发生在任何地方有一天,我运行的代码运行得很好,第二天,却没有碰到我的build.gradle文件或任何其他构建文件,却弹出了此错误

我尝试了许多不同的解决方案,例如更改buildToolsVersion或将AAPT(不记得哪个)的特定标志设置为false没事我的app \
build.gradle文件:

 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'

我得到的错误是:

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

你可能想看:
分享给朋友: