I followed this tutorial here step by step, it works fine on my API 21 emulator, but on my 27 it crashes as soon as the app loads with:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.myapp/com.myapp.myapp.ui.SplashScreenActivity}: android.content.res.Resources$NotFoundException: Drawable com.myapp.myapp:drawable/splash_screen_background with resource ID #0x7f0700a9
My file drawable/splash_screen_background is this one:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:type="radial"
android:gradientRadius="100%p"
android:startColor="@color/primaryColor"
android:endColor="@color/primaryDarkColor"/>
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/ic_home_white_24dp"/>
</item>
</layer-list>
I tried to use app:srcCompat
, pass the drawable directly to the item
eliminating the bitmap
, but the problem persists. I have seen some people saying to use android:drawable=
instead, but they say this crashes on < API 21.
This answer shows some pretty complicated extra configurations, including gradle
options, I am not sure how this will impact my app, does it change the performance of vector graphics?
What's the right way to handle a layer-list
on Android that will work on several APIs?