Java – invalid paintable tag vector – appcompat-v7: 24.1.1
OK, I've read most of the available answers to similar questions, but it doesn't solve my problem
gradle classpath’com.android.tools.build:grad:2.1.2′
android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 24
vectorDrawables.useSupportLibrary = true
}
}
dependencies {
compile 'com.android.support:recyclerview-v7:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:cardview-v7:24.1.1'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:design:24.1.1'
}
activity.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ViewItem"
tools:ignore="MissingPrefix">
...
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="center_vertical"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:foregroundGravity="center_vertical|center|center_horizontal"
app:srcCompat="@drawable/ic_car" />
...
</ScrollView>
vector ic_ car.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="#5c5c5c"
android:pathData="M18.92 6.01C18.72 5.42 18.16 5 17.5 5h-11c-.66 0-1.21 .42 -1.42 1.01L3 12v8c0
.55 .45 1 1 1h1c.55 0 1-.45 1-1v-1h12v1c0 .55 .45 1 1 1h1c.55 0 1-.45
1-1v-8l-2.08-5.99zM6.5 16c-.83 0-1.5-.67-1.5-1.5S5.67 13 6.5 13s1.5 .67 1.5
1.5S7.33 16 6.5 16zm11 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5 .67 1.5
1.5-.67 1.5-1.5 1.5zM5 11l1.5-4.5h11L19 11H5z" />
<path android:pathData="M0 0h24v24H0z" />
</vector>
My activity class extends appcompatactivity, and all Android: SRC tags are changed to app: srccompat, but I still see an invalid drawable tag vector set to 16 on minsdkversion
resolvent:
In my case, the reason for the crash is to use resources. Getdrawable (int) to get the vector drawing on the front lollipop device. I tried to create a drawable and enter ImageView. Setimagedrawable (drawable)
Google Blog Post for Android Support Library 23.2:
Solution: use vectordrawablecompat. Create (resources, int, theme) to create drawable
You can also use ImageView. Setimageresource (int), but this will read / decode the bitmap on the UI thread