Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
flaviojunior opened this issue Oct 1, 2015 · 11 comments
Closed

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

flaviojunior opened this issue Oct 1, 2015 · 11 comments
Assignees
Labels

Comments

@flaviojunior
Copy link

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)
@zhanghai
Copy link
Owner

zhanghai commented Oct 1, 2015

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.

@flaviojunior
Copy link
Author

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!

@zhanghai
Copy link
Owner

zhanghai commented Oct 1, 2015

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.

@flaviojunior
Copy link
Author

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).

@zokipirlo
Copy link

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"/>

@moshtagh
Copy link

moshtagh commented Oct 3, 2015

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)

@zhanghai
Copy link
Owner

zhanghai commented Oct 3, 2015

Can you verify if 7db62ac fixed this?

@zhanghai
Copy link
Owner

zhanghai commented Oct 4, 2015

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

@zhanghai
Copy link
Owner

zhanghai commented Oct 4, 2015

Released.

@zhanghai zhanghai closed this as completed Oct 4, 2015
@zokipirlo
Copy link

Works great now. Tnx.

@flaviojunior
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants