Flutter应用启动图标不生效问题求助
Flutter应用启动图标替换后仍显示默认图标的解决办法
核心问题排查:图标格式
你提供的目标图标是JPG格式,Android和iOS的启动图标均要求使用PNG格式,这大概率是替换失败的关键原因。先将目标图标转换为正方形PNG(建议尺寸≥1024x1024px),再按以下步骤操作。
基于flutter_launcher_icons工具的标准修复流程
更新pubspec.yaml配置
在dev_dependencies下添加依赖,并在文件末尾配置图标路径:dev_dependencies: flutter_launcher_icons: "^0.13.1" # 推荐使用最新版本 flutter_launcher_icons: android: "launcher_icon" ios: true image_path: "assets/icons/app_icon.png" # 替换为你转换后的PNG图标路径 min_sdk_android: 21 # 可选,适配Android 5.0+执行图标生成命令
终端依次运行:flutter pub get flutter pub run flutter_launcher_icons:main
手动排查与修复(工具生成无效时)
Android端
- 检查图标文件:进入
android/app/src/main/res/目录,确认所有mipmap-*文件夹下的ic_launcher.png和ic_launcher_round.png都是目标图标,无默认图标残留。 - 验证Manifest配置:打开
android/app/src/main/AndroidManifest.xml,确保application标签的icon和roundIcon属性指向正确图标:<application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" ...> - 清理缓存:运行
flutter clean,或在Android Studio中执行Build -> Clean Project后重新构建。
iOS端
- 检查Assets配置:打开
ios/Runner.xcworkspace,在Assets.xcassets中找到AppIcon,确认所有尺寸的图标都已替换为目标PNG,无默认图标遗留。 - 验证Info.plist:确保
CFBundleIconFiles和CFBundlePrimaryIcon的配置指向AppIcon,无错误配置。 - 清理缓存:运行
flutter clean,删除ios/Runner/DerivedData文件夹,或在Xcode中执行Product -> Clean Build Folder。
解决系统缓存残留
- 卸载设备/模拟器上的旧应用
- 重启设备(部分系统会缓存图标资源)
- 重新运行项目:
flutter run
内容的提问来源于stack exchange,提问作者walid icam
相关产品推荐
相关产品推荐

