"Splash Screens the Right Way" issue with Andoid 8-9 (vector drawable launcher icon)


On Android 8/9/later it fails with

Caused by: android.content.res.Resources$NotFoundException: File res/drawable/background_splash.xml from drawable resource ID #0x7f07005e

Because it tries to load vector drawable ic_launcher_foreground.xml (mipmap-anydpi-v26/ic_launcher.xml) as launcher icon. bitmap element inside item element of course doesn’t support it (android:src only for normal drawables) and app:srcComp isn’t allowed to be used in this case (items, layer-lists)

But we can use the next solution (it works fine for Vector Drawables):

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/YOUR_COLOR"/>

<item android:drawable="@mipmap/YOUR_DRAWABLE"


Mb it’s better to update that blog page and mention about this issue when using bitmap


actually it’s better to use the old method for API <= 22 Android (with bitmap item) and new one for API >= 23

API <= 19 doesn’t support vector drawables (only ImageView with app:srcCompat)

API 21-22 supports vector drawables but image is stretched to all screen with <item android:drawable="@mipmap/YOUR_DRAWABLE" android:gravity="center"/>

So we need at least 23 API to use <item android:drawable="@mipmap/YOUR_DRAWABLE"/>