You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

flutter_native_splash在Android 12及以上设备首次启动不显示Logo的问题求助

flutter_native_splash在Android 12及以上设备首次启动不显示Logo的问题求助

大家好,我在Flutter项目中使用flutter_native_splash插件实现启动页,在Android 11及以下设备上运行完全正常,但在Android 12及以上的真机上遇到了异常:首次启动App时,启动页只显示设置的背景色,Logo完全不出现;但从第二次启动开始,背景色和Logo就能正常显示了。

有没有朋友遇到过同样的问题?想请教下怎么解决才能让Android 12+设备在首次启动时也能正常显示Logo?

以下是我的相关配置信息:

1. pubspec.yaml 中的 flutter_native_splash 配置

flutter_native_splash:
  image: assets/loginPage/splashScreenELogo.png
  color: "#5C7CFF"
  color_dark: "#5C7CFF"
  fullscreen: true
  android_12:
    image: assets/loginPage/splashScreenELogo.png
    color: "#5C7CFF"
    color_dark: "#5C7CFF"
    fullscreen: true

2. AndroidManifest.xml 配置片段

<application
    android:label="CGPEY"
    android:name="${applicationName}"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:taskAffinity=""
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <meta-data
            android:name="io.flutter.embedding.android.NormalTheme"
            android:resource="@style/NormalTheme"/>
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

3. Android 12+ 对应的 res/values-v31/styles.xml 配置

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <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:windowSplashScreenBackground">#5C7CFF</item>
        <item name="android:windowSplashScreenAnimatedIcon">@drawable/splash</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

4. 启动页Logo图片属性

  • 尺寸:512 x 511
  • 位深度:32
  • 文件大小:8.8 kb

另外,我已经尝试过按照@iamgoddey的建议修改了v31的styles.xml配置,也跟着相关教程重新实现了一遍,但问题依然存在。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 03:08:03