Issue with Gradient Drawable on Android 6 Marshmallow while using Splash Screen API

47 Views Asked by At

I recently migrated my existing splash screen activity to the Splash Screen API, which offers backward compatibility up to API 21. I'm utilizing a vector drawable for the splash screen icon, and it's functioning as expected up to Android 7. However, I'm encountering an issue related to an invalid color state list tag gradient on Android 6 Marshmallow.

The error seems to stem from the following portion of my drawable XML:

<aapt:attr name="android:fillColor">
  <gradient 
      android:startX="45.94"
      android:startY="19.77"
      android:endX="107.75"
      android:endY="121.44"
      android:type="linear">
    <item android:offset="0" android:color="#FF5F9FFF"/>
    <item android:offset="0.27" android:color="#FFA9DCF9"/>
    <item android:offset="0.48" android:color="#FFC6EB98"/>
    <item android:offset="0.59" android:color="#FFDDE855"/>
    <item android:offset="0.7" android:color="#D1F4E50F"/>
    <item android:offset="0.91" android:color="#14DDFF0F"/>
  </gradient>
</aapt:attr>

This works perfectly fine on Android 7, but on Android 6, it's resulting in an "invalid color state list tag gradient" error.

I'd appreciate any insights into why this error is occurring and how I could address it to ensure compatibility with Android 6 while still utilizing the Splash Screen API.

Thank you in advance for your assistance!

One approach could be to provide an alternative drawable like png or jpg specifically for Android 6 devices in the drawable-v21 resource folder.

0

There are 0 best solutions below