Closed jon-adams closed 8 years ago
Thank you for reporting this issue. I should use View.isInEditMode()
for this. Will do it later.
The sample is working properly in my Android Studio 2.0; Maybe it is because I've just updated my gradle plugin version. I'll publish a new version with updated dependencies now.
Please try 1.1.6 version of this library; I cannot reproduce your exception due to #19 , but when viewed in the sample project of this project the preview is ok, so that issue should be a regression.
Updating to v1.1.6 of the library fixed this rendering exception in Android Studio 2.0.
Thanks!
Upon further investigation, maybe this issue isn't totally "fixed". I mean, the preview stopped breaking. (Though sometimes I had to invalidate the Android Studio cache and restart to get the exception to go away.)
However, I still see the following log message in the Warning level logcat output:
W/PropertyValuesHolder: Method set() with type float not found on target class class me.zhanghai.android.materialprogressbar.IndeterminateHorizontalProgressDrawable$RectTransformX
It looks like the same line of code the preview render exception was on? (Guessing, but similar classes and method names involved.)
Perhaps you may want to revisit that bit of code and see if the recent SDK or support library changed signatures underneath you? It's just an Android warning; the progress bar still shows and animates. But you may want to look at it, since I didn't test it across all the device levels we support.
This is #10 ; I did not find out the reason, but it works normally. You can reopen that issue if you really want that one fixed.But it doesn't seem be related to this issue (because if so it shouldn't be introduced by updating Android Studio and fixed by updating gradle plugin.).
Still having this issue in Android Studio 2.1.1
` java.lang.IllegalArgumentException: object is not an instance of declaring class at java.lang.reflect.Method.invoke(Method.java:483) at
lines removed for brevity
me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawableBase.stop ... (IndeterminateProgressDrawableBase.java:65) at me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawable.stop(IndeterminateProgressDrawable.java:18)
lines removed for brevity `
Since Android Studio 2.0, the progress bar throws an exception during rendering and blocks ALL of the views from showing in the preview (because of the exception).
(I think it has something to do with the animation code in the progress bar.)
java.lang.IllegalArgumentException: object is not an instance of declaring class at java.lang.reflect.Method.invoke(Method.java:606) at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108) at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:145) at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java:-1) at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:37) at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1296) at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:981) at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:642) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:589) at android.animation.ValueAnimator.start(ValueAnimator.java:1106) at android.animation.ValueAnimator.start(ValueAnimator.java:1117) at android.animation.ObjectAnimator.start(ObjectAnimator.java:852) at android.animation.AnimatorSet.start(AnimatorSet.java:586) at me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawableBase.start ... (IndeterminateProgressDrawableBase.java:45) at me.zhanghai.android.materialprogressbar.IndeterminateProgressDrawable.start(IndeterminateProgressDrawable.java:19) at android.widget.ProgressBar.drawTrack(ProgressBar.java:1713) at android.widget.ProgressBar.onDraw(ProgressBar.java:1676) at android.view.View.draw(View.java:16178) at android.view.View.draw(View.java:16090) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16088) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16088) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16088) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16181) at android.support.v4.widget.NestedScrollView.draw(NestedScrollView.java:1761) at android.view.View.draw(View.java:16090) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.support.design.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1127) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16088) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16088) at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) at android.view.ViewGroup.drawChild(ViewGroup.java:3609) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) at android.view.View.draw(View.java:16181)
Use the following example layout (really pretty much any layout that includes the ProgressBar will throw the exception) and view the Preview tab in Android Studio 2.0+:
Invalidating caches and restarting does not fix the problem.
When running the code on a device or emulator, the progress bar shows correctly and animates correctly. This is only a problem when rendering the Preview. The annoying thing is that not only does it not render, but it keeps all the other views from rendering in the preview. Hiding the view with
tools:visibility="gone"
won't stop it from crashing the whole preview render.This occurs while using
compile 'me.zhanghai.android.materialprogressbar:library:1.1.4'