尝试在VSCode和Flutter中调试时,突然出现Gradle Error

问题描述 投票:2回答:2

我在调试时突然遇到错误,它只是正常工作,当我尝试在main.dart中加载新屏幕时弹出这个错误。

错误

在调试模式下为x86构建的Android SDK上启动lib \ main.dart ...

FAILURE:构建因异常而失败。

  • 出了什么问题:任务':app:processDebugResources'执行失败。 Android资源链接失败输出:C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:225:错误:资源android:attr / fontVariationSettings not found。 C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:225:错误:资源android:attr / ttcIndex未找到。错误:链接引用失败。 命令:C:\ Users \ Sam.gradle \ _caches \ transforms-1 \ files-1.1 \ aapt2-3.2.1-4818971-windows.jar \ a2fedb806fdcf1039dc8366793f0d803 \ aapt2-3.2.1-4818971-windows \ aapt2.exe链接 - 我\ C:\ Users \ Sam \ AppData \ Local \ Android \ sdk \ platforms \ android-27 \ android.jar \ --manifest \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ merged_manifests \ debug \ processDebugManifest \ merged \ AndroidManifest.xml \ -o \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ processed_res \ debug \ processDebugResources \ out \ resources-debug.ap_ \ -R \ @C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ incremental \ processDebugResources \ resources-list-for-resources-debug.ap_.txt \ --auto-add-overlay \ --java \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ generated \ not_namespaced_r_class_sources \ debug \ processDebugResources \ r \ --custom-package \ com.example.lightbridgemobile \ -0 \ apk \ --output-text-symbols \ C:\ LightBridge_Mobile \ lightbridge_mobile \ Li ghtBridge \ build \ app \ intermediates \ symbols \ debug \ R.txt \ --no-version-vectors守护程序:AAPT2 aapt2-3.2.1-4818971-windows守护程序#0输出:C:\ Users \ Sam.gradle \ caches \ transforms-1 \ files-1.1 \ core-1.0.0.aar \ 44d43b22d49402bbb3cf830f8d41ead1 \ res \ values \ values.xml:89:5-125:25:AAPT:错误:资源android:attr / fontVariationSettings not found。 C:\ Users \ Sam.gradle \ _caches \ transforms-1 \ files-1.1 \ core-1.0.0.aar \ 44d43b22d49402bbb3cf830f8d41ead1 \ res \ values \ values.xml:89:5-125:25:AAPT:错误:资源android:attr / ttcIndex未找到。 错误:链接引用失败。命令:C:\ Users \ Sam.gradle \ _caches \ transforms-1 \ files-1.1 \ aapt2-3.2.1-4818971-windows.jar \ a2fedb806fdcf1039dc8366793f0d803 \ aapt2-3.2.1-4818971-windows \ aapt2.exe链接 - 我\ C:\ Users \ Sam \ AppData \ Local \ Android \ sdk \ platforms \ android-27 \ android.jar \ --manifest \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ merged_manifests \ debug \ processDebugManifest \ merged \ AndroidManifest.xml \ -o \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ processed_res \ debug \ processDebugResources \ out \ resources-debug.ap_ \ -R \ @C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ intermediates \ incremental \ processDebugResources \ resources-list-for-resources-debug.ap_.txt \ --auto-add-overlay \ --java \ C:\ LightBridge_Mobile \ lightbridge_mobile \ LightBridge \ build \ app \ generated \ not_namespaced_r_class_sources \ debug \ processDebugResources \ r \ --custom-package \ com.example.lightbridgemobile \ -0 \ apk \ --output-text-symbols \ C:\ LightBridge_Mobile \ lightbridge_mobile \ Li ghtBridge \ build \ app \ intermediates \ symbols \ debug \ R.txt \ --no-version-vectors守护进程:AAPT2 aapt2-3.2.1-4818971-windows守护进程#0
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。
  • https://help.gradle.org获得更多帮助

建于18世纪的失败


Gradle失败可能是因为此Flutter应用中的AndroidX不兼容。


Gradle任务assembleDebug失败,退出代码1退出(sigterm)

android dart flutter android-gradle
2个回答
1
投票

从类似的SO问题中复制我自己的答案(Android version no longer working after upgrading flutter packages

我几天前看到类似的错误,发现我需要升级我的项目以支持AndroidX。

我能够迁移flutter项目以支持AndroidX,而无需使用Android工作室。

这是我做的:

  1. compileSdkVersion文件中的build.gradle更新为28
  2. 和gradle.properties中的android.useAndroidX=trueandroid.enableJetifier=true

编辑:如果您看到无法合并dex错误,请参阅This SO post,其中包含(1)尝试清理和重建OR(2)在app/build.gradle文件中添加以下内容:

android {
    defaultConfig {
       multiDexEnabled true
    }
}

希望这可以帮助!


0
投票

我能够通过编辑compileSDK值来解决这个问题。我把它从27改为28。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.