You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter构建报错Execution failed for task ':app:processDebugResources'如何解决?

问题诱因

该错误属于Android资源编译(AAPT)阶段的类型不匹配问题,核心原因是AndroidManifest.xml中引用的drawable/launch_background资源,与对应属性要求的资源类型不符合,常见触发场景如下:

  • 应用图标属性错误引用:在android:icon/android:roundIcon等要求mipmap图标资源的属性位,误用了启动页专属的drawable类型的launch_background资源
  • launch_background资源本身格式错误:android/app/src/main/res/drawable目录下的launch_background.xml存在语法错误、根标签不符合drawable资源规范,导致AAPT无法将其识别为合法的drawable资源
  • 编译缓存异常:项目增量编译产生的缓存冲突,导致合并后的AndroidManifest和资源索引不匹配
排查修复步骤
  1. 核对AndroidManifest报错行属性配置
    打开报错路径对应的AndroidManifest.xml,定位第53行:
    • 如果该行是应用图标配置项,将@drawable/launch_background替换为mipmap目录下的图标资源,示例:@mipmap/ic_launcher
    • 如果该行是启动页相关配置,确认属性要求的资源类型确实为drawable
  2. 校验launch_background资源合法性
    打开android/app/src/main/res/drawable/launch_background.xml,核对文件格式是否符合规范,合法示例如下:
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <!-- 启动页背景色 -->
        <item android:drawable="@android:color/white" />
        <!-- 启动页居中logo -->
        <item>
            <bitmap
                android:gravity="center"
                android:src="@mipmap/launch_logo" />
        </item>
    </layer-list>
    
    修正文件内的标签未闭合、属性拼写错误、非法根标签等问题
  3. 清理缓存重新构建
    如果上述配置都无异常,执行以下命令清理缓存后重试:
    • 执行flutter clean清理项目编译产物
    • 执行flutter pub get重新拉取依赖
    • 重新启动项目构建

内容的提问来源于stack exchange,提问作者junior_flutter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 13:15:04