在使用flutter_launcher_icons更改应用程序图标后,我在运行flutter run
和flutter build apk
后开始出现此问题:
flutter build apk -debug
/Users/pitol/.gradle/caches/transforms-3/dfcbd5820ba82f60df3a20d93f4b43e6/transformed/core-1.8.0/res/values/values.xml:5:4: Invalid <color> for given resource value.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed (Failed to compile values resource file /Users/pitol/workspace/3i/chat-bot/school_chat_bot_app/build/app/intermediates/incremental/release/mergeReleaseResources/merged.dir/values/values.xml. Cause: java.lang.IllegalStateException: Can not extract resource from com.android.aaptcompiler.ParsedResource@1f60c2b3.). Check logs for more details.
* 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 14s
Running Gradle task 'assembleRelease'... 14.5s
Gradle task assembleRelease failed with exit code 1
字符串
“invalid given resourse”是这个:<color name="androidx_core_secondary_text_default_material_light">#8a000000</color>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr format="reference" name="nestedScrollViewStyle"/>
<color name="androidx_core_ripple_material_light">#1f000000</color>
<color name="androidx_core_secondary_text_default_material_light">#8a000000</color>
<color name="notification_action_color_filter">#ffffffff</color>
<color name="notification_icon_bg_color">#ff9e9e9e</color>
<dimen name="compat_button_inset_horizontal_material">4dp</dimen>
...
型
(It的生成文件位于/Users/pitol/. gradle/caches/transforms-3/dfcbd 5820 ba 82 f60 df 3a 20 d93 f4 b43 e6/transformed/core-1.8.0/res/values/values. xml)
尝试运行flutter doctor -v
,解决了所有的依赖关系,更新了android studio,更新了Java,当我尝试构建android应用程序时仍然得到这个错误(doctor -v命令显示没有错误);
已经在Mac和Windows上尝试过了,它显示了相同的错误;
我还尝试创建一个新的flutter项目,并成功地构建了,所以问题出在项目上,而不是框架上;
1条答案
按热度按时间ubof19bj1#
**第一步:**删除项目中所有flutter_launcher_icons生成的
.png
文件;**第二步:**从
pubspec.yaml
中删除flutter_launcher_icon实现;**第三步:**删除
.../android/app/src/main/res/values/colors.xml
文件;**第四步:**删除
.../android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
文件;**第五步:**运行
flutter clean
;**第六步:**运行
flutter pub get
;**第七步:**运行
flutter doctor -v
,确保所需平台没有依赖;**第八步:**尝试运行或构建APK(
flutter run
或flutter build apk -debug
);**第9步:**如果应用构建正确,您可以尝试再次导入flutter_launcher_icons并遵循他们的
readme
步骤。但这一次,保持启动器图标文件的名称与他们的pubspec示例相同;**第十步:**确认之前删除的
.xml
文件没有被再次创建,运行/构建应用;