flutter_native_splash icon indicating copy to clipboard operation
flutter_native_splash copied to clipboard

splash showing only background on apk installation launch

Open shetuolindo opened this issue 10 months ago • 15 comments

ISSUE: Flutter native splash is showing only the background when launched right after installing with APK (first launch). But when later opened the, the main image and branding is shown. When installing directly from VS Code to physical or virtual device, the logo and the branding is displayed.

What I want: When the app is first installed and launched, the splash screen should display a logo in the middle and a branding logo at the bottom.

What I have tried: Since I was using a separate .yaml file for the splash screen, as per some tutorials and the documentation, I used the following commands in my project directory:

flutter clean
flutter pub get
dart run flutter_native_splash:create --path=native_splash.yaml

Since the issue was still there I tried shifting everything from my native_splash.yaml to my pubspec.yaml and it made no changes.

The following are my codes.

main.dart

void main() async {
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  await Future.delayed(
    const Duration(seconds: 3),
  );
  FlutterNativeSplash.remove();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    SystemChrome.setPreferredOrientations([
      DeviceOrientation.portraitUp,
      DeviceOrientation.portraitDown,
    ]);
    return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      initialRoute: AppRoute.homeScreen,
      getPages: PageScervice.list,
    );
  }
}

native_splash.yaml

flutter_native_splash:
  color: "#BBDEFB"
  image: "assets/logo-main.png"
  branding: "assets/logo-branding.png"
  android: true
  ios: true
  web: false
  android_12:
    color: "#BBDEFB"
    image: "assets/logo-main.png"
    branding: "assets/logo-branding.png"
    icon_background_color: "#BBDEFB"
  fullscreen: true

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">

        <item name="android:windowBackground">@drawable/launch_background</item>
        <item name="android:forceDarkAllowed">false</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
        <item name="android:windowIsTranslucent">true</item> 

    </style>

    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

shetuolindo avatar Feb 24 '25 04:02 shetuolindo

I am facing the same issue. I am using a Redmi Note 13 device (Xiaomi HyperOS, Android 14), and even after running flutter_native_splash:create, only the background color changes, but my splash image does not appear at all.

bullets-jyr avatar Mar 05 '25 02:03 bullets-jyr

It's completely true. I am facing the same issue too. My splash image does not appear at all. It's just showing the background color only.

recsater-hajong avatar Mar 06 '25 15:03 recsater-hajong

@shetuolindo @recsater-hajong what device and OS are you running?

jonbhanson avatar Mar 09 '25 21:03 jonbhanson

@jonbhanson Poco X3 GT. Android 13, with MIUI 14

shetuolindo avatar Mar 09 '25 21:03 shetuolindo

@jonbhanson Redmi Note 13 device (Xiaomi HyperOS, Android 14)

bullets-jyr avatar Mar 10 '25 04:03 bullets-jyr

I've also experienced this behavior (on a Pixel 9, Android Version 15). Interestingly enough, if I install the APK and then go back to the home screen and launch the app from there, I can see the logo within the splash screen.

b-nugent avatar Mar 10 '25 15:03 b-nugent

@jonbhanson Samsung Galaxy A23, Android 14, One UI 6.1

recsater-hajong avatar Mar 10 '25 20:03 recsater-hajong

Same here, asus zenfone 9 Android 14

gianpaolodn avatar Mar 18 '25 16:03 gianpaolodn

Same wrong behavior on OnePlus Nord (Android 12) as written above.

Note: For me it is acceptable that when the app is installed, and started next time, the logo appears correctly.

vborbely avatar Apr 03 '25 14:04 vborbely

same issues

shabanov-krl avatar Apr 04 '25 20:04 shabanov-krl

Add this line to your styles.xml file:

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

It is a new setting added in Android 13. More information: https://developer.android.com/develop/ui/views/launch/splash-screen

I think the package should be updated to reflect this.

MichalPleban avatar Apr 09 '25 22:04 MichalPleban

same issue + when the user updatesthe application, it's only showsthe background color without the logo

khaledsawan avatar May 22 '25 08:05 khaledsawan

Add this line to your styles.xml file:

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

It is a new setting added in Android 13. More information: https://developer.android.com/develop/ui/views/launch/splash-screen

I think the package should be updated to reflect this.

Thanks for this @MichalPleban. @shetuolindo do you have feedback of if this has solved your problem?

jonbhanson avatar Oct 17 '25 02:10 jonbhanson

Same issues, even generating a new apk with the suggestion, it still doesn't work

LeonardoCamargo31 avatar Oct 22 '25 19:10 LeonardoCamargo31

@jonbhanson The issue is still there. When I install the app via apk, during the first launch, the splash screen does not show the image. But shows later.

shetuolindo avatar Oct 28 '25 09:10 shetuolindo