skip to Main Content

i’m trying to use flutter_launcher_icons 0.14.1 to create launcher icon for my flutter app. i followed the instructions in the pubdev of it
and when i ran dart run flutter_launcher_icons, this is the output

Built flutter_launcher_icons:flutter_launcher_icons.
  ════════════════════════════════════════════
     FLUTTER LAUNCHER ICONS (v0.14.1)
  ════════════════════════════════════════════

• Creating default icons Android
• Overwriting the default Android launcher icon with a new icon
• Creating mipmap xml file Android
• Overwriting default iOS launcher icon with new icon
Creating Icons for Web...
Creating Icons for Windows...
Creating Icons for MacOS...

Creating Icons for Web...
Creating Icons for Windows...
Creating Icons for MacOS...

✓ Successfully generated launcher icons

so i guessed everything must be fine but when i run the app again this error shows:

E/AndroidRuntime(23044): FATAL EXCEPTION: wmshell.splashworker
E/AndroidRuntime(23044): Process: com.android.systemui, PID: 23044
E/AndroidRuntime(23044): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.draw(android.graphics.Canvas)' on a null object reference
E/AndroidRuntime(23044):    at com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$AdaptiveForegroundDrawable.draw(SplashscreenIconDrawableFactory.java:269)
E/AndroidRuntime(23044):    at com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$ImmobileIconDrawable.preDrawIcon(SplashscreenIconDrawableFactory.java:131)
E/AndroidRuntime(23044):    at com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$ImmobileIconDrawable.lambda$new$1(SplashscreenIconDrawableFactory.java:117)
E/AndroidRuntime(23044):    at com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$ImmobileIconDrawable.$r8$lambda$0odOtiiVhAkJamazINpBnODkLdw(Unknown Source:0)
E/AndroidRuntime(23044):    at com.android.wm.shell.startingsurface.SplashscreenIconDrawableFactory$ImmobileIconDrawable$$ExternalSyntheticLambda0.run(Unknown Source:6)
E/AndroidRuntime(23044):    at android.os.Handler.handleCallback(Handler.java:942)
E/AndroidRuntime(23044):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(23044):    at android.os.Looper.loopOnce(Looper.java:240)
E/AndroidRuntime(23044):    at android.os.Looper.loop(Looper.java:351)
E/AndroidRuntime(23044):    at android.os.HandlerThread.run(HandlerThread.java:67)

this is my pubspec.yaml

name: activity_app
description: 'A new Flutter project.'
publish_to: 'none'
version: 0.1.0

environment:
  sdk: '>=3.3.1 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_screenutil: ^5.9.1
  http: ^1.2.1
  provider: ^6.1.2
  table_calendar: ^3.1.1
  intl: ^0.19.0
  bottom_picker: ^2.7.0
  crypto: ^3.0.3
  shared_preferences: ^2.3.2
  intl_phone_number_input: ^0.7.4
  url_launcher: ^6.3.0
  firebase_core: ^3.6.0
  firebase_messaging: ^15.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.0
  flutter_launcher_icons: ^0.14.1

flutter_launcher_icons:
  image_path_android: 'assets/cm_launcher_icon.png'
  image_path_ios: 'assets/cm_launcher_icon.png'
  android: true
  ios: true
  min_sdk_android: 21
  remove_alpha_ios: true
  web:
    generate: true
    image_path: 'assets/cm_launcher_icon.png'
    background_color: '#F9F9F9'
    theme_color: '#F9F9F9'
  windows:
    generate: true
    image_path: 'assets/cm_launcher_icon.png'
    icon_size: 48
  macos:
    generate: true
    image_path: 'assets/cm_launcher_icon.png'

flutter:
  uses-material-design: true

  assets:
    - assets/cm_launcher_icon.png
    - assets/cm_logo.webp
    - assets/cm_icon.webp
    - assets/cm_and_nu_icon.webp

i’ve tried flutter clean -> flutter pub get -> dart run flutter_launcher_icons -> run the flutter app, the error is still showing and the launcher icon is the android logo. i’ve tried to chatgpt and claude this but they can’t seem to figure it out.

2

Answers


  1. Chosen as BEST ANSWER

    found the solution in https://github.com/fluttercommunity/flutter_launcher_icons/issues/595

    remove the mipmap-anydpi-v26 folder in android/app/src/main/res


  2. I’m not sure if it is should be necessary, but on Android you can also specify the adaptive icon foreground and background.

    https://pub.dev/packages/flutter_launcher_icons#android

    Which are themed icons for Android 13+. On what Android version are you running your app? If it is 13/14, it might be worth it to try adding adaptive icon specs to your configuration/running on an older device/emulator to see if it works there.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search