zhanghai/MaterialProgressBar

"java.lang.NumberFormatException: Invalid int:" on API 17

Closed this issue · 11 comments

API 17
Style: Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding

 Caused by: java.lang.NumberFormatException: Invalid int: ".0dip"
        at java.lang.Integer.invalidInt(Integer.java:138)
        at java.lang.Integer.parse(Integer.java:375)
        at java.lang.Integer.parseInt(Integer.java:366)
        at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
        at android.content.res.TypedArray.getInt(TypedArray.java:254)
        at me.zhanghai.android.materialprogressbar.MaterialProgressBar.init(MaterialProgressBar.java:74)
        at me.zhanghai.android.materialprogressbar.MaterialProgressBar.<init>(MaterialProgressBar.java:39)

Is this crash specific to this style, that using other styles won't cause any problem?

Which version of this library are you using? The current stable is 1.1.3.

In MaterialProgressBar.init(), there are only two references to TypedArray.getInt(), which is on app:mpb_progressStyle and android:tintMode, which both can not be dimensions, so I wonder why there are .0dip inside the stacktrace. Nor do I have the literal '.0dp' in any of the library styles.

The error occurs in all styles and behaviors.
I was using version 1.1.2 and now updated to 1.1.3.

The code a.getInt(styleable.MaterialProgressBar_android_tintMode, -1) is returning .0dip.

In my project there is no occurrence of .0dip.

Thank you!

Did you specify an android:tint? What attributes did you specify? Are you using a samsung device?

I just found that android:tintMode is added in API 21, unlike android:tint in API 1. I guess this can be a resource attr id collision. If so, an app:tintMode should be added.

My component:
< me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/pgbActivityIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
app:mpb_progressStyle="horizontal"
app:mpb_useIntrinsicPadding="false"
android:visibility="invisible"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" />

I'm trying to test in the emulator (ARM API 17).

I received this on Galaxy Nexus (4.3)

Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable-xhdpi/ic_go_search_api_holo_light.png"
     at java.lang.Integer.invalidInt(Integer.java:138)
     at java.lang.Integer.parse(Integer.java:375)
     at java.lang.Integer.parseInt(Integer.java:366)
     at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:122)
     at android.content.res.TypedArray.getInt(TypedArray.java:254)
     at me.zhanghai.android.materialprogressbar.MaterialProgressBar.init(MaterialProgressBar.java:80)
     at me.zhanghai.android.materialprogressbar.MaterialProgressBar.<init>(MaterialProgressBar.java:45)
     at java.lang.reflect.Constructor.constructNative(Native Method) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
     at android.view.LayoutInflater.createView(LayoutInflater.java:594) 
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 
     at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) 
     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) 

Using it like that

<me.zhanghai.android.materialprogressbar.MaterialProgressBar
            android:id="@+id/download_progressbar"
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:max="100"
            android:visibility="invisible"
            android:indeterminate="false"
            app:mpb_progressStyle="horizontal"
            app:mpb_setBothDrawables="true"
            style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"/>

i have the same problem on huaweri, android: 4.2.1

Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable-xhdpi/ic_find_next_holo_light.png"
        at java.lang.Integer.invalidInt(Integer.java:138)
        at java.lang.Integer.parse(Integer.java:375)
        at java.lang.Integer.parseInt(Integer.java:366)
        at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
        at android.content.res.TypedArray.getInt(TypedArray.java:257)
        at me.zhanghai.android.materialprogressbar.MaterialProgressBar.init(MaterialProgressBar.java:80)
        at me.zhanghai.android.materialprogressbar.MaterialProgressBar.<init>(MaterialProgressBar.java:45)

Can you verify if 7db62ac fixed this?

Reproduced with sample app on API 17 (but not on API 15), fixed in commit 512ca0f, will be released soon.

Released.

Works great now. Tnx.

Thank you!