react-native-bootsplash迁移后Android启动图标显示异常问题
Android端react-native-bootsplash v6迁移后启动页Logo不符问题排查方案
1. 清理旧资源与缓存
- 检查Android项目
res/drawable-*、res/drawable-night-*目录,删除所有v4版本遗留的bootsplash相关Logo文件 - 执行gradle清理命令,彻底清除缓存:
cd android && ./gradlew clean - 重新打包安装应用,避免旧资源被复用
2. 验证资源生成与配置匹配
- 重新执行资源生成命令,确保指定的Logo路径和参数正确:
npx react-native generate-bootsplash assets/your-target-logo.png --background-color=#你的背景色 - 检查
android/app/src/main/res/values/styles.xml中的BootTheme配置,确认bootSplashLogo引用的是最新生成的drawable:<style name="BootTheme" parent="Theme.BootSplash"> <item name="bootSplashBackground">@color/bootsplash_background</item> <item name="bootSplashLogo">@drawable/bootsplash_logo</item> <item name="bootSplashAnimationDuration">1000</item> </style> - 确认
AndroidManifest.xml中主Activity的android:theme已设置为@style/BootTheme
3. 适配RN 0.72的资源规则
- 若开启了资源压缩,在
android/app/src/main/res/raw/keep.xml中添加bootsplash资源的保留规则,防止Logo被误压缩:<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@drawable/bootsplash_*,@color/bootsplash_*" /> - 检查
android/app/build.gradle中的compileSdkVersion、targetSdkVersion是否与RN 0.72要求一致(需≥33),避免资源编译不兼容
4. 深色模式资源检查
- 查看
res/drawable-night-mdpi、res/drawable-night-hdpi等深色模式目录,确认其中的bootsplash_logo文件是你指定的深色版本Logo,若生成错误可手动替换对应文件
内容的提问来源于stack exchange,提问作者Nischit
相关产品推荐
相关产品推荐

