Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XmlPullParserException: invalid drawable tag vector

I am using NDK support and getting this error:

Gradle:

Distribution: gradle-2.5-all

Build tool: gradle-experimental:0.2.1

XML:

    <vector android:height="24dp" android:viewportHeight="125.0"
android:viewportWidth="100.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M97.01,-2.98,-3C47.02,95.35"/>
</vector>

Warning:

vector requires API level 21 (current min is 13) or building with Android Gradle plugin 1.4 or higher

Exception:

  FATAL EXCEPTION: main
 android.content.res.Resources$NotFoundException: File res/drawable/accelerometer.xml from drawable resource ID #0x7f020045
 at android.content.res.Resources.loadDrawable(Resources.java:2842)
 at android.content.res.Resources.getDrawable(Resources.java:1521)

...
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
 at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:917)
 at android.graphics.drawable.Drawable.createFromXml(Drawable.java:858)
like image 992
Malwinder Singh Avatar asked Dec 29 '15 15:12

Malwinder Singh


1 Answers

On pre-Lollipop devices you need to use VectorDrawableCompat to get your vector from resources.

 someVectorDrawable = VectorDrawableCompat.create(context.getResources(), R.drawable.[some res id], null);

Then you can set your ImageView's background.

like image 163
Tyler Howes Avatar answered Oct 17 '22 01:10

Tyler Howes