Choreographer NullPointerException

I have been working on an existing codebase for a while and browsing through our emergency log service. I noticed an exception that happens quite often, I canโ€™t reproduce this problem, and I donโ€™t have the context for the script to try to dig, since this is a rather large project, it is becoming increasingly difficult to find out the reason for this exception.

I searched the Internet for similar problems and did not find any useful information. If anyone is familiar with this problem, your help would be greatly appreciated.

Stacktrace is as follows:

java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:487) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:517) at android.animation.ValueAnimator.start(ValueAnimator.java:936) at android.animation.ValueAnimator.start(ValueAnimator.java:946) at android.animation.ObjectAnimator.start(ObjectAnimator.java:465) at android.animation.AnimatorSet$1.onAnimationEnd(AnimatorSet.java:579) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1056) at android.animation.ValueAnimator.access$400(ValueAnimator.java:50) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:644) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:660) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) at android.view.Choreographer.doCallbacks(Choreographer.java:574) at android.view.Choreographer.doFrame(Choreographer.java:543) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) at android.os.Handler.handleCallback(Handler.java:733) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5105) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) at dalvik.system.NativeStart.main(NativeStart.java) 

Greetings.

+8
android nullpointerexception
source share
7 answers

The problem turned out to be an animation called from Handler using postDelayed() , which ultimately led to an attempt to animate the null View link because it was not properly cleared according to it host life cycle events.

+6
source share

maybe you have a null tag, print log with animatorSet.getTarget () to see

+3
source share

I also get this stack trace when I use: ObjectAnimator animator = ObjectAnimator.ofFloat (this is "scale", 1); .... animator.start ()

run in android 4.0.X, but this is normal for a higher version, you can also refer to this commit commit how to fix it, however this is a definite reason.

+2
source share

Now I went through this exception and found out that I was getting an instance of the view with animation from getActivity().findViewById . Although I was in a fragment , I had to create it from a root list, inflated, containing a view.

I basically moved the view from the Activity layout to Fragment, but didn't change the code. This way rootview.findViewById solved my problem.

My stack:

 java.lang.NullPointerException at android.animation.PropertyValuesHolder.setupSetterAndGetter(PropertyValuesHolder.java:505) at android.animation.ObjectAnimator.initAnimation(ObjectAnimator.java:392) at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:495) at android.animation.ValueAnimator.start(ValueAnimator.java:913) at android.animation.ValueAnimator.start(ValueAnimator.java:923) at android.animation.ObjectAnimator.start(ObjectAnimator.java:370) at eu.davidea.passwordcloud.ui.ItemDetailFragment$3.onClick(ItemDetailFragment.java:162) at android.view.View.performClick(View.java:4084) at android.view.View$PerformClick.run(View.java:16966) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) 
0
source share

Believe me, I found a solution to this crash problem on 4.0.x devices.

The problem is that you are using an ObjectAnimator without the "start" and "end" values, api on 4.0.x devices cannot find the "start" value for implementation.

For example, this will crash on devices 4.0.x

 int endRadiusValue = 10; ObjectAnimator .ofFloat(roundedGradientDrawable, "cornerRadius", endRadiusValue) .setDuration(200) .start(); 

And this code works on all api level devices

 int startRadiusValue = 0; int endRadiusValue = 10; ObjectAnimator .ofFloat(roundedGradientDrawable, "cornerRadius", startRadiusValue, endRadiusValue) .setDuration(200) .start(); 
0
source share

The reason is the target view is null . ObjectAnimator ofFloat(Object target, ...) .
This failure will be thrown only on 4 devices.
There is no failure on the other device

0
source share

enter image description here

I solve the problem by adding animation to the animation set like this:

-one
source share

All Articles