Flutter 无法构建发布 apk 得到“Android 资源链接失败”

Flutter cannot build release apk got " Android resource linking failed"

我能够构建调试 apk 但在创建发布 apk 时遇到此错误。

[+17902 ms] FAILURE: Build failed with an exception.
[   +1 ms] * What went wrong:
[        ] Execution failed for task ':flutter_exif_rotation:verifyReleaseResources'.
[        ] > A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
[        ]    > Android resource linking failed
[        ]      ERROR:C:\Users\app\.gradle\caches\transforms-34b95f651786cc8f7db1990724e58bd\transformed\core-1.6.0\res\values-v21\values-v21.xml:3:5-118: AAPT: error: resource
color/androidx_core_secondary_text_default_material_light (aka io.flutter.plugins.flutterexifrotation:color/androidx_core_secondary_text_default_material_light) not found.
[        ]      ERROR:C:\Users\app\.gradle\caches\transforms-34b95f651786cc8f7db1990724e58bd\transformed\core-1.6.0\res\values-v21\values-v21.xml:14:5-18:13: AAPT: error:
resource color/androidx_core_secondary_text_default_material_light (aka io.flutter.plugins.flutterexifrotation:color/androidx_core_secondary_text_default_material_light) not found.
[        ]      ERROR:C:\Users\app\.gradle\caches\transforms-34b95f651786cc8f7db1990724e58bd\transformed\core-1.6.0\res\values-v21\values-v21.xml:14:5-18:13: AAPT: error:
resource dimen/notification_action_text_size (aka io.flutter.plugins.flutterexifrotation:dimen/notification_action_text_size) not found.
[        ] * Try:
[        ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[        ] * Get more help at https://help.gradle.org
[        ] BUILD FAILED in 3m 34s

您应该在 android studio 中打开 android 项目(在项目目录中寻找 android)参考 this

然后,就可以报错了,在你修复了android项目类型上所有与android环境相关的问题后,构建成功,就可以回到flutter项目中正常工作了

执行 flutter clean 解决了问题