React Native Android端如何正确配置应用图标 解决最小化显示默认图标问题
安卓最近任务栏应用图标显示异常解决方案
问题根源
Android 8.0(API 26)及以上版本系统中,最近任务栏的应用图标优先读取roundIcon属性或自适应图标配置,主屏幕图标因为兼容旧版规范所以显示正常,因此会出现两端显示不一致的问题。
修复步骤
- 第一步:修改
AndroidManifest.xml配置
打开android/app/src/main/AndroidManifest.xml文件,定位到application节点,确保同时配置了android:icon和android:roundIcon两个属性,指向你自定义的图标资源:<application android:name=".MainApplication" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" <!-- 其余原有配置保持不变 --> > - 第二步:补全图标资源
检查android/app/src/main/res/下的所有mipmap文件夹:各dpi对应的mipmap-mdpi、mipmap-hdpi、mipmap-xhdpi、mipmap-xxhdpi、mipmap-xxxhdpi目录下,必须同时存在
ic_launcher.png和ic_launcher_round.png两套图标文件
如果项目使用了自适应图标,还需要确认res/mipmap-anydpi-v26目录下的ic_launcher.xml和ic_launcher_round.xml中配置的前景、背景图片资源路径正确 - 第三步:重新打包生效
- 运行
./gradlew clean命令清理构建缓存 - 完全卸载测试设备上的原有应用
- 重新编译安装应用即可
- 运行
问题参考截图



内容的提问来源于stack exchange,提问作者Joshi G
相关产品推荐
相关产品推荐

