I'm trying to add a launch icon to my Flutter app, for now I'm only concerned about Android. I've installed the flutter_launcher_icons package and tried a few different things, but the phone is only showing some default empty icon (a puzzle piece with a blue background on one phone, and just a black box on another). Here's the lines from my pubspec.yaml file:
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.14.0"
flutter_launcher_icons:
android: "launcher_icon"
ios: false
image_path: "assets/icon/icon.png"
adaptive_icon_background: "#5F8F3C"
remove_alpha_ios: true
min_sdk_android: 21
The launcher_icon files are there in the android/app/src/main/res/ folders, and it's the correct image (though the background is not there, but I'm not sure if it handles that at a later time). The AndroidManifest.xml file has line android:icon="@mipmap/launcher_icon"
. I'm really not sure what's wrong here. The original image has dimensions 512x512.
As stated in the documentation:
Adaptive Icons will only be generated when both
adaptive_icon_background
andadaptive_icon_foreground
are specified. (theimage_path
is not automatically taken as the foreground)
To fix the issue, you need to specify the adaptive_icon_foreground
in your pubspec.yaml file:
flutter_launcher_icons:
android: "launcher_icon"
ios: false
image_path: "assets/icon/icon.png"
adaptive_icon_foreground: "assets/icon/icon.png" # Set the foreground image (same or different from image_path)
adaptive_icon_background: "#5F8F3C"
remove_alpha_ios: true
min_sdk_android: 21
Note:
You may need to run flutter clean
and then flutter pub get
to ensure that the changes take effect. If the issue persists, try deleting the android folder and recreating it by running flutter create . --platforms android
.