XmlPullParserException Binary XML file line #17 vector tag requires viewportWidth 0
A previous answer to this question had a solution for developers who use Gradle, but I don't use Gradle so I want to summarize his answer which helped several people and what I eventually did. I accepted my own answer and not his since like I said, I don't use Gradle so I did not use what he wrote.
I did several things for it to work in the end. Possible solutions are:
First for Gradle users:
1) Revert the support library to an older version, since this one has a bug.
2) use compile 'com.android.support:appcompat-v7:23.2.1' as the bug was fixed there.
3) for Gradle Plugin 2.0:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Or you can use Grade Build Tools 1.5.0 (classpath 'com.android.tools.build:gradle:1.5.0'
)
defaultConfig {
generatedDensities = []
}
// no need for this with Gradle 2.0
aaptOptions {
additionalParameters "--no-version-vectors"
}
This is the part for non Gradle users:
1) Open SDK manager.
2) Uninstalled both "Android Wear X" (where X is ARM or Intel) from APIs 22 and 23.
3) I then still had a compilation error in one of the styles of the AppCompat library. I simply commented them out (I'll risk the very specific device not working if it uses that very specific style).
After that I cleaned the project and it just started to work.
Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17 vector tag requires viewportWidth 0
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
Using android support library 23.2 in build.gradle crashes app (XmlPullParserException: XmlPullParserException: invalid drawable tag vector)
It turned out there were two separate issues:
- I was using a plain
RadioButton
in my XML files. Changing it toandroid.support.v7.widget.AppCompatRadioButton
fixed the problem. Second, as the blog post was suggesting I had to wrap some of the drawables into container drawables so the support library could use them when doing vector based drawing. For example, in one of my custom buttons, I had vector based background saved in
dialog_bg.xml
,button_round_bg.xml
andbutton_round_bg_2.xml
.To fix that I had to put them in one of the containers (such as State list, Inset or LevelList). This wrapper was saved to a filed called
vector_wrapper.xlm
:
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/dialog_bg"
android:maxLevel="1"
android:minLevel="1" />
<item
android:drawable="@drawable/button_round_bg"
android:maxLevel="2"
android:minLevel="2" />
<item
android:drawable="@drawable/button_round_bg_2"
android:maxLevel="3"
android:minLevel="3" />
</level-list>
Now I would change my custom button's background to say
<customButton
android:background="@drawable/vector_wrapper"
</customButton>
Since the wrapper now has three drawables, I can select them in the Java code according to my needs:
customButton btnSave = (customButton) view.findViewById(R.id.btnSave);
btnSave.getBackground().setLevel(3);
You do not need to the container wrapper if your view is Image
-based view as the other answer by @themichaelscott is suggesting, in that case just change the src to app:srcCompat="@drawable/ic_add"
Cannot inflate toolbar on pre L devices
Found the answer: https://medium.com/@chrisbanes/appcompat-v23-2-age-of-the-vectors-91cbafa87c88#.adypg3azu
Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0
Seems that updating to support library 23.2.0 will cause this problem
For those who don't want to make further details, you only need to do the following:
If you have Gradle
version 2.0 or above:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
or if you have version 1.5 or below:
android {
defaultConfig {
// Stops the Gradle plugin’s automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Android support library 23.2.0 error in setting style=@style/Widget.AppCompat.Button.Colored
I tested on other machine and its a bug in support library version 23.2.0
So I've reported it on
AOSP issue tracker here.
If you are having same issue...do star the issue on above link.
Thanks.
UPDATE
Here comes the support library version 23.2.1...
works like a charm!!
UPDATE
Here comes the Support lib 23.3.0...
and the charm goes away...
complete story here.
I guess support library needs to be well tested before final release..
Appcompat Activity Giving issues for version 24.0.0
replace you gradle version
classpath 'com.android.tools.build:gradle:2.1.3'
Related Topics
Android Gridlayout with Dynamic Number of Columns Per Row
How to Autoplay HTML5 Mp4 Video on Android
Making a Triangle Shape Using Xml Definitions
Getexternalstoragepublicdirectory Deprecated in Android Q
Error: Fix the Version Conflict (Google-Services Plugin)
The APK File Does Not Exist on Disk
Android - How to Unregister a Receiver Created in the Manifest
Update Fragment from Viewpager
Deleting Android Sms Programmatically
Android Emulator: Could Not Get Wglgetextensionsstringarb Error
How to Create and Read Log on Android Devices
Error: No Resource Identifier Found for Attribute 'Adsize' in Package 'Com.Google.Example' Main.Xml
Filtering Listview with Custom (Object) Adapter
Blue Dot and Circle Is Not Shown on Mylocation Using Android Fused Location API
Android Imagebutton with a Selected State
How to Check If an Activity Is the Last One in the Activity Stack for an Application