Flutter - 生成 flutter app apk 时出错

Flutter - error generating flutter app apk

我一直在尝试使用 cmd 中的 flutter build apk --release 创建我的应用程序的 apk,但是每次我 运行 这个命令时我都会收到这个错误:

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':unique_identifier:verifyReleaseResources'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade 1 exception was raised by workers: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed C:\Users\.gradle\caches\transforms-2\files-2.1871fd20009e8811e4cb86c0e32da7a\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found. C:\Users\.gradle\caches\transforms-2\files-2.1871fd20009e8811e4cb86c0e32da7a\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.

BUILD FAILED in 4m 26s Running Gradle task 'assembleRelease'... Running Gradle task 'assembleRelease'... Done 267,5s The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility. Building plugin device_info... The plugin device_info could not be built due to the issue above. Running Gradle task 'assembleAarRelease'... /

扑博士:

[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [versão 10.0.19041.985], locale pt-BR)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.0)
[√] VS Code (version 1.56.2)
[√] Connected device (3 available)
  1. 在您的项目文件夹中添加此行 > android > app > build.gradle,

    multiDexEnabled true

在默认配置中。

  1. 在android/build.gradle文件中升级gradle依赖:类路径'com.android.tools.build:gradle:3.3.1'(之前版本3.2.1)

  2. 运行 flutter 清理并重建你的项目

还有请参考这个https://flutter.dev/docs/development/androidx-migration