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.36k stars 215 forks source link

[Android] app icon not showing on Android 12 #681

Closed toando0612 closed 3 months ago

toando0612 commented 8 months ago

Describe the bug:

My Issue:

image

The result that I want:

image

When I run Physical Device and Emulator with Android 12. Splash Screen show, but only have background color. App icon not display.In addition, there were two results if I kill the Application and open it again: Emulator: app icon shown when open again Physical Xiaomi Device: app icon still not display, only see background color as before

-My issue currently happening on (Android 12). -Android 13 and above working OK. -Android below 12 working OK. -Only happen with Android 12

This is my flutter_native_splash.yaml:

flutter_native_splash:
  image: assets/images/launch_image.png
  image_dark: assets/images/launch_image.png

  android_12:
    color: "#F14D89"
    color_dark: "#F14D89"
    image: assets/images/app_logo.png
    image_dark: assets/images/app_logo.png

  web: false
  android: true
  ios: false

Devices: Physical: Xiaomi 11T 12 SP1A, MIUI Global 13.0.5 Emulator: Pixel_6a_API_31 Emulator: Pixel_6a_API_34

To Reproduce

  1. Run Application on Emulator/Physical Android 12 devices
  2. Kill the app
  3. Open app again
jonbhanson commented 8 months ago

Did you check out the notes at the bottom of the Android 12 section?

toando0612 commented 8 months ago

Did you check out the notes at the bottom of the Android 12 section?

Thank you for your response! Yes, I checked that, but it still an issue with my app. I used PNG image 1152x1152 to generate app icon as description. In addition, I built apk and release apk to physical device. I opened app many times (cold start). The problem still happen, I cannot see app icon. I am trying to check everything again and still not find solution yet, anyway, highly appreciated you supports

nicoolle commented 8 months ago

I have the same issue

2x2xplz commented 7 months ago

Hi, I am also experiencing this. Was developing on a physical device running Android 12 and I could set the splash screen's background color but no matter what, the image did not appear on the splash screen. Tried an emulator running Android 13 and it works fine, image shows up. After seeing this issue, I built an Android 12 emulator and once again, no image.

My image is exactly 1152x1152 as specified, PNG with transparent background. However I tested with other image sizes and none of them showed up either on my physical Android 12 device.

Thank you.

2x2xplz commented 7 months ago

OK unfortunately this appears to be a longstanding known issue with Android. See https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying and https://issuetracker.google.com/issues/205021357?pli=1

The StackOverflow checked response indicates that the icon won't show when the app is launched from Android Studio but it does show if the app is launched from the default launcher. Personally this is still not working on my physical device, however I do see it working on the emulated Android 12. The emulated device is a Pixel with default Pixel launcher while my physical device is not a Pixel and runs a third-party launcher. The issue tracker also seems to indicate that some launching scenarios won't show the icon, such as launching from a notification.

Definitely annoying but it doesn't appear that this package has any ability to "fix" this issue.

Hi, I am also experiencing this. Was developing on a physical device running Android 12 and I could set the splash screen's background color but no matter what, the image did not appear on the splash screen. Tried an emulator running Android 13 and it works fine, image shows up. After seeing this issue, I built an Android 12 emulator and once again, no image.

My image is exactly 1152x1152 as specified, PNG with transparent background. However I tested with other image sizes and none of them showed up either on my physical Android 12 device.

Thank you.

jonbhanson commented 7 months ago

@toando0612 is your issue different from the issue referenced (https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying and https://issuetracker.google.com/issues/205021357?pli=1)? If it is the same, it is related to Android API 31, and not Flutter or this package.

toando0612 commented 7 months ago

@toando0612 is your issue different from the issue referenced (https://stackoverflow.com/questions/69812590/android-12-splash-screen-icon-not-displaying and https://issuetracker.google.com/issues/205021357?pli=1)? If it is the same, it is related to Android API 31, and not Flutter or this package.

Still not found solution yet, do you have any idea to fix this? I tried other images as middle app icon. It displays background color only, no app icon at all

RoyalCoder88 commented 4 months ago

I have the same issue :( any fixes guys?

jonbhanson commented 4 months ago

@toando0612 please upload a minimal project the reproduces the problem so I can assist. Make sure to strip out anything proprietary or secret like API keys.

LNMCode commented 4 months ago

Im facing with the same issue. pls fix it

Baksman commented 4 months ago

Still having the issue on android 12 notifications

jonbhanson commented 3 months ago

Without a minimal project that reproduces the problem as requested, I cannot help resolve this problem. Closing due to inactivity. Feel free to reopen with an example minimal project that demonstrates the problem if you are still having trouble.

jkano commented 2 months ago

For everyone coming here this is what worked for me, I have a physical Xiaomi device and it is not running pixel launcher, on emulator shows the icon but in my device it doesn't.

I added the following line to the styles.xml files inside both folders value-v31 and value-night-v31 (android/app/src/main/res/):

<item name="android:windowSplashScreenBehavior">icon_preferred</item>

I added it inside the "LaunchTheme" resource like this:

<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
    <item name="android:forceDarkAllowed">false</item>
    <item name="android:windowFullscreen">false</item>
    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
    <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
    <item name="android:windowSplashScreenBackground">#42a5f5</item>
    <item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
    <item name="android:windowSplashScreenIconBackgroundColor">#42a5f5</item>
    <item name="android:windowSplashScreenBehavior">icon_preferred</item> <!--  Added here --->
</style>

I see that the generator doesn't add this line so I think @jonbhanson you can add that line to the generator and that will solve the icon not being shown on Android 12+ devices running non-pixel launchers.

jonbhanson commented 2 weeks ago

@toando0612 can you verify if @jkano's solution fixes your problem?