Android Studio报AAPT错误:未找到mipmap/ic_launcher_round资源怎么办
报错场景
开发Android TabLayout项目时触发AAPT构建错误,关联Manifest资源校验环节,核心报错信息:
PC\AndroidStudioProjects\TabLayout\app\build\intermediates\packaged_manifests\debug\AndroidManifest.xml:12: AAPT: error: resource mipmap/ic_launcher_round (aka com.example.tablayout:mipmap/ic_launcher_round) not found
构建日志明确提示未找到mipmap/ic_launcher_round资源。
常见触发原因
- 手动清理项目冗余资源时,误删了各分辨率mipmap目录下的
ic_launcher_round相关文件(含png图、自适应图标xml配置) - 替换应用启动图标时,仅替换了常规启动图标
ic_launcher,未同步提供圆形版本的ic_launcher_round资源 - 模块级
build.gradle配置了自定义资源目录,未将存放启动图标的mipmap路径纳入资源扫描范围 - AndroidManifest的
<application>标签中声明了圆形启动图标属性,但项目内实际未提供对应资源
修复方案
选择以下任意一种方案即可解决问题:
- 方案1:补全圆形启动图标资源
右键项目的res目录,依次选择New > Image Asset,图标类型选择Launcher Icons (Adaptive and Legacy),资源命名为ic_launcher_round,上传对应图标素材后确认生成全分辨率资源,重新构建项目即可。 - 方案2:移除圆形图标引用
打开app/src/main/AndroidManifest.xml,定位到<application>节点,删除android:roundIcon="@mipmap/ic_launcher_round"属性,之后在Android Studio终端执行./gradlew clean清理构建缓存,重新编译即可。 - 方案3:复用常规启动图标作为圆形图标
不需要单独设计圆形图标时,可直接将各mipmap分桶目录下的ic_launcher资源复制一份,重命名为ic_launcher_round;针对自适应图标(API26+),在res/mipmap-anydpi-v26目录下新建ic_launcher_round.xml,写入如下配置即可:<?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@mipmap/ic_launcher_background"/> <foreground android:drawable="@mipmap/ic_launcher_foreground"/> </adaptive-icon>
内容的提问来源于stack exchange,提问作者Ahmed Abubaker
相关产品推荐
相关产品推荐

