windowSplashScreenAnimatableIcon not found

Viewed 5207

I want to customize my splash screen on Android 12 and I get the AAPT error:

AAPT: error: style attribute 'android:attr/windowSplashScreenAnimatableIcon' not found.

Here is the relevant part of the style:

<style name="SplashTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:windowSplashScreenAnimatableIcon">@drawable/ic_splash</item>
</style>

That is the attribute mentioned in the documentation.

Here is an overview of the build tool libs I'm using:

compileSdk="android-S"
minSdk=21
targetSdk="S"
buildTools='31.0.0-rc4'

I use Android Studio Arctic Fox | 2020.3.1 Beta 1 just for the records.

Can someone point out what I'm doing wrong?

2 Answers

It seems that the documentation is wrong/outdated. The right attribute is:

<item name="android:windowSplashScreenAnimatedIcon">@drawable/ic_splash</item>

The correct attribute is listed in the R.attr class.


In a previous version of this answer I had a way to keep the splashscreen working as before, however this does not work anymore.

Today I suggest to use the splash compat library and this style:

<style name="SplashTheme" parent="Theme.SplashScreen">
    <item name="windowSplashScreenBackground">@color/ic_launcher_background</item>
    <item name="windowSplashScreenAnimatedIcon">@drawable/ic_launcher_foreground</item>
    <item name="postSplashScreenTheme">@style/Your.Normal.Theme</item>
</style>

This has the two assumptions that you use a adaptive launcher icon with the default namings. In my case ic_launcher_background is a solid color this is why I'm using color instead of drawable prefix. I hope that helps others.

Here is the guide for the splash migration from Google.

For anyone who has issues customising splash screen make sure you are using the correct parent theme

Instead of

<style name="SplashTheme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
    <item name="android:windowSplashScreenAnimatableIcon">@drawable/ic_splash</item>
</style>

use

<style name="SplashTheme" parent="Theme.SplashScreen">
    <item name="android:windowSplashScreenAnimatableIcon">@drawable/ic_splash</item>
    <item name="postSplashScreenTheme">@style/Your.Normal.Theme</item>
</style>
Related