flutterdartflutter-launcher-icons

suspected flutter_launcher_icons 0.14.1 causing FATAL EXCEPTION: wmshell.splashworker


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.


Solution

  • 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