Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0

Solution 1:

Use this code in your build.gradle file

    //for Gradle Plugin 2.0+  
 android {  
   defaultConfig {  
     vectorDrawables.useSupportLibrary = true  
    }  
 }

If you are using Gradle 1.5 you’ll instead use

defaultConfig {
        generatedDensities = []
    }

    // This is handled for you by the 2.0+ Gradle Plugin
    aaptOptions {
        additionalParameters "--no-version-vectors"
    }

I think may be they are using vector draw-able compact underneath in other lib.found here

Solution 2:

You can also upgrade to 23.4.0

dependencies {
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.4.0'
}

and use a flag to manually enable this functionality:

static
{
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}

inside the activity that uses the vectors.

Source: Age of the vectors

Solution 3:

Please remove the appcompat gradle( compile "com.android.support:appcompat-v7:23.2.0") and replace with support design (compile 'com.android.support:design:23.1.1') this will solve the problem

Solution 4:

On pre-lollipop devices you need to create selector to use VectorDrawable elsewhere from ImageView

app:srcCompat="@drawable/your_vector_drawable"

Selector:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/your_vector_drawable" />

</selector>

Then you can pass this selector, e.g. for TextView drawableLeft/drawableRight in xml

<TextView
        android:gravity="center_vertical"
        android:drawableLeft="@drawable/selector_your_vector_drawable"
        android:drawableStart="@drawable/selector_your_vector_drawable"
        android:drawableRight="@drawable/selector_your_vector_drawable"
        android:drawableEnd="@drawable/selector_your_vector_drawable"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/your_string" />

Solution 5:

Instead of ContextCompat.getDrawable , just use AppCompatDrawableManager.get().getDrawable .

This should work on versions higher than 23.+