jonbhanson / flutter_native_splash

Automatically generates native code for adding splash screens in Android and iOS. Customize with specific platform, background color and splash image.
https://pub.dev/packages/flutter_native_splash
MIT License
1.28k stars 200 forks source link

Splash screen stays white #649

Closed lukehutch closed 3 months ago

lukehutch commented 4 months ago

Describe the bug

I run flutter_native_splash:create, using the lines in pubspec.yaml shown below. This gives this output:

[Android] Creating default splash images
[Android] Updating launch background(s) with splash image path...
[Android]  - android/app/src/main/res/drawable/launch_background.xml
[Android]  - android/app/src/main/res/drawable-v21/launch_background.xml
[Android] Updating styles...
[Android]  - android/app/src/main/res/values-v31/styles.xml
[Android]  - android/app/src/main/res/values-night-v31/styles.xml
[Android]  - android/app/src/main/res/values/styles.xml
[Android]  - android/app/src/main/res/values-night/styles.xml
[iOS] Creating  images
[iOS] Updating ios/Runner/Info.plist for status bar hidden/visible
[Web] Creating images
[Web] Creating images
[Web] Creating background images
[Web] Creating CSS
[Web] Updating index.html

I see that drawable/background.png is created in the correct background color, at 1x1 pixel.

However, when I rebuild and run my app, the background stays white.

Configuration

flutter_native_splash:
  color: "#ffc107"
  image: assets/icon/icon-splash.png

Device (please complete the following information):

To Reproduce

As above, 100% reproducibility, but I can't share the project, sorry.

What can I do to debug this further?

jonbhanson commented 4 months ago

To configure Android 12+ (API 33) you must use the android_12 section.

lukehutch commented 4 months ago

Thanks, that works. Maybe the docs should be updated to more clearly indicated that this is needed for Android versions over 12, not just Android 12? Or maybe that should even be the default now, since it is very rare (especially in Flutter) to build apps for Android 11 or below, at this point.

Also, if I specify android_12, I still have to specify the color and/or image for earlier Android versions, otherwise I get an error.

Maybe the user could just specify the minimum Android SDK version to build for, and then flutter_native_splash could figure out what to build?

jonbhanson commented 3 months ago

Excellent suggestion, thank you. I have been planning to rework the plugin to be Android 12+ first, and the feedback from you and others confirms this is needed.