如何解决Android Studio构建时AAPT报mipmap资源不存在的错误
ERROR:C:\Users\Alex\AndroidStudioProjects\Lm2\app\src\main\res\mipmap-anydpi-v26\ic_launcher_round.xml:3: AAPT: error: resource mipmap/ic_launcher_background (aka com.example.lm2:mipmap/ic_launcher_background) not found.
错误原因
该报错由自适应圆形启动图标配置文件引用的背景资源缺失导致:ic_launcher_round.xml中指定使用mipmap/ic_launcher_background作为图标背景,但项目对应目录下不存在该资源文件。
解决方法
- 补全缺失资源:将命名为
ic_launcher_background的图标背景素材(支持png、webp、矢量xml格式)放入所有对应dpi的mipmap目录,若为通用背景可直接放入res/drawable目录。 - 修改资源引用路径:打开
mipmap-anydpi-v26/ic_launcher_round.xml,将第3行引用@mipmap/ic_launcher_background的代码,替换为实际存在的背景资源路径,例如背景存放在drawable目录则改为@drawable/实际背景文件名。 - 应急跳过自适应图标:打开
AndroidManifest.xml,注释或删除android:roundIcon="@mipmap/ic_launcher_round"配置,直接使用普通启动图标即可正常构建。 - 自动生成启动图标:右键点击项目
res目录,选择「New > Image Asset」,跟随系统向导重新生成自适应启动图标,Android Studio会自动补齐所有需要的资源和配置文件,无需手动调整。
内容的提问来源于stack exchange,提问作者Auric Keeper
相关产品推荐
相关产品推荐

