splash showing only background on apk installation launch
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>
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.
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.
@shetuolindo @recsater-hajong what device and OS are you running?
@jonbhanson Poco X3 GT. Android 13, with MIUI 14
@jonbhanson Redmi Note 13 device (Xiaomi HyperOS, Android 14)
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.
@jonbhanson Samsung Galaxy A23, Android 14, One UI 6.1
Same here, asus zenfone 9 Android 14
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.
same issues
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.
same issue + when the user updatesthe application, it's only showsthe background color without the logo
Add this line to your
styles.xmlfile:<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?
Same issues, even generating a new apk with the suggestion, it still doesn't work
@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.