React Native Splash Screen Dark Circle on MIUI Devices
Hello developers. I’m Feyyaz. I would like to share with you an error I encountered while developing a mobile application with react-native in the past weeks. You always want to test your app before putting it into production. You can try various ways for this, but it is not possible for all conditions.
While working with the react-native-splash-screen library, I encountered a bug that only affects dark mode on my Redmi Note 9 Pro Max (in Turkey, Redmi Note 9 Pro) test device. After some research, I concluded that the error is related to MIUI. The core developer of the library, Mathieu, has already mentioned it on his Github issue here. After noticing the error, I realized that some application also has this error in production. So the error affects not only react-native applications but also some native applications, I guess.
Normally the splash screen should look like this:
But because of the error, it looks like this:
To solve the error, Mathieu offered a two-step solution:
1. Create a compat_splash_screen_no_icon_background.xml file in android/app/src/main/res/drawable-v23
2. Fill it with:
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
<color android:color="?attr/windowSplashScreenBackground" />
android:height="@dimen/splashscreen_icon_size_no_background" /><!-- We mask the outer bounds of the icon like we do on Android 12 -->
<solid android:color="@android:color/transparent" />
In my file path, the file named drawable-v23 was not in the res folder, but this file needs to be created for it to work.
Finally, I would like to thank Mathieu for his interest.
Do not forget to follow my articles for errors and solutions that may come up during my application development phase. Goodbye 💥