Android 11无法显示应用XML格式图标,求解决方法
解决Android 11+显示通用应用图标的问题
核心原因
Android 8.0(API 26)及以上系统要求应用提供自适应图标(Adaptive Icons),仅使用传统的@drawable/app_icon XML图标无法满足新版本系统的图标规范,因此会 fallback 到系统默认的Android机器人图标。
具体修复步骤
1. 创建自适应图标资源
在res目录下新建mipmap-anydpi-v26文件夹,然后创建两个XML文件:
ic_launcher.xml(自适应图标容器)ic_launcher_round.xml(圆形自适应图标容器,适配部分启动器)
ic_launcher.xml示例代码:
<?xml version="1.0" encoding="utf-8"?> <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@drawable/ic_launcher_background" /> <foreground android:drawable="@drawable/app_icon" /> </adaptive-icon>
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="@drawable/ic_launcher_background" /> <foreground android:drawable="@drawable/app_icon" /> </adaptive-icon>
其中ic_launcher_background为图标背景,可使用纯色或渐变Drawable,示例:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#FFFFFF" /> <!-- 替换为你需要的背景色 --> </shape>
2. 更新AndroidManifest配置
将原有图标配置改为引用mipmap下的自适应图标:
<application ... android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" ...>
3. 兼容低版本系统
在mipmap-hdpi、mipmap-mdpi等传统分辨率文件夹中保留对应尺寸的图标资源(可以是app_icon的位图版本,或继续使用XML),确保Android 8以下设备正常显示。
4. 清理缓存并重装应用
在Android 11设备上:
- 卸载现有应用
- 清理Android Studio构建缓存(点击
File > Invalidate Caches... > Invalidate and Restart) - 重新编译安装应用
验证注意事项
- 部分启动器可能需要重启设备才能刷新图标缓存
- 确保所有mipmap文件夹下的图标资源命名一致,避免资源找不到的情况
内容的提问来源于stack exchange,提问作者aarelovich
相关产品推荐
相关产品推荐

