Material-dialogs: Still issue with AppCompat v23.2.1 and Vector on Pre-Lollipop

Created on 20 Mar 2016  路  18Comments  路  Source: afollestad/material-dialogs

Here's the logcat

/VectorDrawableCompat: parser error
                                           org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
                                               at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
                                               at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
                                               at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
                                               at android.support.graphics.drawable.VectorDrawableCompat.create(VectorDrawableCompat.java:418)
                                               at com.afollestad.materialdialogs.internal.MDTintHelper.setTint(MDTintHelper.java:135)
                                               at aj.jair.music.pref.MaterialCheckBoxPreference.initDecoration(MaterialCheckBoxPreference.java:32)
                                               at aj.jair.music.pref.MaterialCheckBoxPreference.<init>(MaterialCheckBoxPreference.java:23)
                                               at java.lang.reflect.Constructor.constructNative(Native Method)
                                               at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                                               at android.view.LayoutInflater.createView(LayoutInflater.java:594)
                                               at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
                                               at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
                                               at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
                                               at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
                                               at android.preference.Preference.onCreateView(Preference.java:489)
                                               at android.preference.Preference.getView(Preference.java:460)
                                               at android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:221)
                                               at android.widget.AbsListView.obtainView(AbsListView.java:2255)
                                               at android.widget.ListView.makeAndAddView(ListView.java:1790)
                                               at android.widget.ListView.fillDown(ListView.java:691)
                                               at android.widget.ListView.fillFromTop(ListView.java:752)
                                               at android.widget.ListView.layoutChildren(ListView.java:1630)
                                               at android.widget.AbsListView.onLayout(AbsListView.java:2087)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                               at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                               at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                               at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                               at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                               at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                               at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                               at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                               at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                                               at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                                               at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
                                               at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                                               at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                                               at android.view.View.layout(View.java:14817)
                                               at android.view.ViewGroup.layout(ViewGroup.java:4631)
bug

Most helpful comment

_Workaround_ till the library is updated

  1. Use AppCompat v23.2.1
  2. Use material-dialog library with version 0.8.5.5

I have used it and the app doesn't crash on any Android version.

All 18 comments

Same problem here. Fail to parse vector drawable.
class: MDTintHelper
method:setTint
Drawable radioVector = VectorDrawableCompat.create(radioButton.getContext().getResources(), R.drawable.abc_btn_radio_material, null);
RadioVector is null.

I think that error is because R.drawable.abc_btn_radio_material point to non vector images...

Correct method:

public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color) {
        ColorStateList sl = new ColorStateList(new int[][]{
                new int[]{-android.R.attr.state_checked},
                new int[]{android.R.attr.state_checked}
        }, new int[]{
                DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal),
                color
        });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            radioButton.setButtonTintList(sl);
        } else {
//            Drawable radioVector = VectorDrawableCompat.create(radioButton.getContext().getResources(),
//                    R.drawable.btn_radio_material, null);
            Drawable radioVector = ResourcesCompat.getDrawable(radioButton.getContext().getResources(),
                    R.drawable.abc_btn_radio_material, radioButton.getContext().getTheme());
            Drawable d = DrawableCompat.wrap(radioVector);
            DrawableCompat.setTintList(d, sl);
            radioButton.setButtonDrawable(d);
        }
    }

Could someone please give an AppCompat - Material Dialogs version combination that doesn't have this issue, as a temporary workaround until this issue gets fixed?

Could we modify MDTintHelper.java in our project?

You can import library as module into your projects until it will be fixed.

@muratogat The workaround for this library to work is

  1. Use AppCompat v23.2.1
  2. Use material-dialog library with version 0.8.5.5

I have used it and the app doesn't crash on any Android version.

Great! Thanks a lot @AkshayChordiya . I confirm that v23.2.1 - 0.8.5.5 versions are compatible.

I also have this problem.

+1

This thread might be helpful for anyone still struggling with vector drawables:
http://stackoverflow.com/questions/35693288/android-studio-1-5-1-could-not-find-property-vectordrawables

i have got the same issue but this combination is working with me:

  • AppCompat v23.2.1
  • material-dialog v0.8.5.6

_Workaround_ till the library is updated

  1. Use AppCompat v23.2.1
  2. Use material-dialog library with version 0.8.5.5

I have used it and the app doesn't crash on any Android version.

I forgot to close this issue, but this problem should've been fixed with release 0.8.5.8.

For me this doesn't seems to be fixed. I tried Version 0.8.5.8 with AppCompat v23.2.1 and AppCompat v23.3.0 and still got the errors.

0.8.5.6 and AppCompat v23.2.1 is my combination for getting no errors.

@Servus7 this is the latest version of the sample project running on a 4.4 emulator, there's definitely no issues (as long as your app is using the same versions of the Google libs as the library is):

screenshot_20160511-114209

@afollestad I'm so sorry. My drawable was in the wrong folder. After moving it from from drawable-nodpi to drawable everything works fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

palaima picture palaima  路  4Comments

MFlisar picture MFlisar  路  3Comments

imcloud picture imcloud  路  5Comments

ghost1372 picture ghost1372  路  5Comments

sarthak1996 picture sarthak1996  路  6Comments