Im trying to use vector drawables on pre lollipop devices. I did all as instructed here but i still get this crash.
build.gradle:
I'm surprised that this is not mentioned here yet.
This crash happens often with:
android:drawableRight
android:drawableLeft
android:drawableTop
android:drawableBottom
android:drawableStart
android:drawableEnd
A common fix is to create another drawable that wraps the drawable with
, or to set the compound drawable using code, but nowadays you can instead use:
app:drawableRightCompat
app:drawableLeftCompat
app:drawableTopCompat
app:drawableBottomCompat
app:drawableStartCompat
app:drawableEndCompat
This was added to AppCompatTextView
in appcompat 1.1.0-alpha01.
To use the attribute I've had to use AppCompat views instead of usual ones, eg. I've used AppCompatButton
instead of Button
.
Not sure if you set vectorDrawables.useSupportLibrary true
and AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
(I have both). Check this article from Nick Butcher: https://medium.com/androiddevelopers/using-vector-assets-in-android-apps-4318fd662eb9.