Reputation: 17848
I'm getting following error and I don't know why (this error is VERY RARE and not reproducable for me):
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setBounds(int, int, int, int)' on a null object reference
at android.widget.ImageView.animateTransform(ImageView.java:1126)
at android.transition.ChangeImageTransform$2.set(ChangeImageTransform.java:64)
at android.transition.ChangeImageTransform$2.set(ChangeImageTransform.java:61)
at android.animation.PropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:938)
at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:952)
at android.animation.ValueAnimator.animationFrame(ValueAnimator.java:1207)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1248)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:659)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:682)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:549)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5321)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)
I think it has to do with the android Fragment
and Activity
transitions, but I'm not sure... The above is the complete stacktrace.
Maybe interesting, I'm using the support-library
Does anyone have an idea where this comes from and how I can prevent it?
EDIT
As written in the comments:
EDIT2
I did not know that I have to make sure an ImageView
does have a content. This may lead to the above error, an ImageView
that does not have an image yet.
Upvotes: 8
Views: 4598
Reputation: 289
I followed answer made by @BladeCoder in this thread. His solution was just one part if you used Universal Image Loader.
After adding placeholder to ImageView, you need also to put some image or color (depends of your needs) to XML.
Upvotes: 0
Reputation: 12929
A Fragment or Activity transition is trying to animate an ImageView which has no drawable set. Ensure you always have a Drawable set for your ImageView when you animate it with ChangeImageTransform (or disable this kind of animation)
Upvotes: 12