Splashscreen API not showing icon

Viewed 499

We are currently implementing a splashscreen via the new Splashscreen API. We are following the migration guide. The background color is set correctly (by windowSplashScreenBackground), but the icon is not visible, neither on an Emulator, nor on a physical device.

build.gradle

android {
    compileSdkVersion 31
    ...
}

dependencies {
    implementation "androidx.core:core-splashscreen:1.0.0-alpha01"
    ...
}

values-v31/themes.xml

<style name="AppTheme" parent="Theme.SplashScreen">
    <item name="postSplashScreenTheme">@style/AppThemeCompat</item>
    <item name="windowSplashScreenBackground">@android:color/black</item>
    <item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
    <item name="windowSplashScreenAnimationDuration">200</item>
</style>

AndroidManifest.xml

<application
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    ...
</application>

MainActivity.kt

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen()
    ...
}
1 Answers

I am answering this question directly as we found the solution to our problem within one or two hours that could be saved from other developers:

Icons set by the Splashscreen API do not work when starting an app from Android Studio. If the app gets closed and then restarted, the icon shows correctly.

This bug might exist due to the early alpha status of this library and will allegedly be fixed in a future version of the Splashscreen API.

Related