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

React Native Android启动屏问题:react-native-bootsplash图标不显示

React Native BootSplash 启动屏不显示图标排查方案

核心检查与修复项

  • 图标资源有效性验证
    你配置的@mipmap/bootsplash_logo必须存在于android/app/src/main/res/mipmap-*全分辨率目录下(mdpi/hdpi/xhdpi/xxhdpi/xxxhdpi),文件名与引用完全一致(大小写敏感)。如果是手动添加资源,建议改用库的CLI命令生成标准资源:

    npx react-native generate-bootsplash assets/your-logo.png
    
  • 主题配置补全与兼容性调整
    检查BootTheme的配置是否完整,AndroidX SplashScreen对图标显示有额外参数要求,补充配置并确保父主题兼容:

    <style name="BootTheme" parent="Theme.SplashScreen">
      <item name="windowSplashScreenBackground">@color/bootsplash_background</item>
      <item name="windowSplashScreenAnimatedIcon">@mipmap/bootsplash_logo</item>
      <item name="postSplashScreenTheme">@style/AppTheme</item>
      <!-- 新增:解决图标不显示的关键配置 -->
      <item name="windowSplashScreenIconBackgroundColor">@color/bootsplash_background</item>
      <item name="windowSplashScreenAnimationDuration">500</item>
    </style>
    

    同时确认@color/bootsplash_background已在res/values/colors.xml中定义,避免因资源缺失导致加载失败。

  • MainActivity初始化顺序确认
    严格保证RNBootSplash.init(this)在super.onCreate()之前执行,若使用react-native-screens需替换参数为null:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      RNBootSplash.init(this);
      super.onCreate(null); // 适配react-native-screens场景
    }
    
  • 依赖版本匹配修复
    升级androidx.core:core-splashscreen至最新稳定版(如1.0.1),同时确保react-native-bootsplash为最新版本,避免版本兼容冲突。

  • 清理缓存重建项目
    执行命令彻底清理缓存后重新构建:

    cd android && ./gradlew clean && cd ..
    npx react-native run-android
    

额外排查手段

  • 查看Android Studio Logcat,搜索SplashScreen关键词,定位资源加载失败的报错(如Resource not found)。
  • 临时将windowSplashScreenAnimatedIcon替换为系统默认图标@mipmap/ic_launcher,验证是否能正常显示,排除图标资源本身问题。

内容的提问来源于stack exchange,提问作者volkavo nosky

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 06:39:15