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
NullPointerException when the animation end #91
Comments
The demo apk, downloaded from the readme file? BTW. Which Android version you are using? |
me too. But version is 5.0+, it's OK . Why ? |
我在5.0版本,没有问题,在4.2测试报错和楼上一样,请问作者这是什么原因? |
I tried it on 4.4.4 and 4.1.1, it is giving the same exception. Though it doesn't crash when I try the example provided at the top right. |
@wzgl5533 @mandeep-vratesh Which lib version you are trying? |
I try it according to your step,Do you test your code on version 4+? |
@daimajia I followed the readme. So it's 2.2 |
@wzgl5533 @mandeep-vratesh Could any one show me the code context? For helping me to address the problem. |
Got the same problem with this (on a Samsung Galaxy S3 with android 4.4): YoYo.with(Techniques.Shake)
.duration(700)
.repeat(-1)
.delay(3000)
.playOn(download) where download is a Button I got a NPE that crashs my app after 2 shakes (at the end of the second shake ?)
java.lang.NullPointerException
at android.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd (AnimatorSet.java : 797)
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.r un (Choreographer.java : 813)
at android.view.Choreographer.doCallbacks (Choreographer.java : 613)
at android.view.Choreographer.doFrame (Choreographer.java : 582)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java : 799)
at android.os.Handler.handleCallback (Handler.java : 733)
at android.os.Handler.dispatchMessage (Handler.java : 95)
at android.os.Looper.loop (Lo oper.java : 146)
at android.app.ActivityThread.main (ActivityThread.java : 5679)
at java.lang.reflect.Method.invokeNativeNative Method
at java.lang.reflect.Method.invoke (Method.java : 515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java : 1291)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java : 1107)
at dalvik.system.NativeStart.mainNative Method |
Could this be related to this issue (observed in another library) ? Basically : on some devices, touching the view hierarchy in on Animation End make it throw an Exception |
I guess you are passing a null object. and may be the problem with repeat() function because after first time when you came again the object is null ... |
Anyone found a solution to this ? |
The screen doesn't change when the issue appears : I grepped some code and I think that the issue and the stack trace leads to the folowing version of AnimatorSet (android 4.4.4 r_1) : http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.4_r1/android/animation/AnimatorSet.java#AnimatorSet Node animNode = mAnimatorSet.mNodeMap.get(animation) at line 796 returns null and then line 797 throws
792 @SuppressWarnings("unchecked")
793 public void More ...onAnimationEnd(Animator animation) {
794 animation.removeListener(this);
795 mPlayingSet.remove(animation);
796 Node animNode = mAnimatorSet.mNodeMap.get(animation);
797 animNode.done = true;
798 if (!mTerminated) {
799 // Listeners are already notified of the AnimatorSet ending in cancel() or
800 // end(); the logic below only kicks in when animations end normally
801 ArrayList<Node> sortedNodes = mAnimatorSet.mSortedNodes;
802 boolean allDone = true;
803 int numSortedNodes = sortedNodes.size();
804 for (int i = 0; i < numSortedNodes; ++i) {
805 if (!sortedNodes.get(i).done) {
806 allDone = false;
807 break;
808 }
809 }
810 if (allDone) {
811 // If this was the last child animation to end, then notify listeners that this
812 // AnimatorSet has ended
813 if (mListeners != null) {
814 ArrayList<AnimatorListener> tmpListeners =
815 (ArrayList<AnimatorListener>) mListeners.clone();
816 int numListeners = tmpListeners.size();
817 for (int i = 0; i < numListeners; ++i) {
818 tmpListeners.get(i).onAnimationEnd(mAnimatorSet);
819 }
820 }
821 mAnimatorSet.mStarted = false;
822 mAnimatorSet.mPaused = false;
823 }
824 }
825 } As Said before, the only animation code I'm using is YoYo.with(Techniques.Shake) on a Button whose name is download and which is inflated, layed out and not null |
investigating further : mNodeMap is mostly used in builders... and in the clone() method that is used to repeat the animation. And it looks like they changed the implementation of clone() between 4.4.4_r1 and 5.1.0_r1 So there might be something wrong with the clone() method... for 4.4.4 |
A workaround for this issue is to handle the repeat process yourself, Observable.interval(2000, 3700, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe {
YoYo.with(Techniques.Shake)
//.delay(3000)
.duration(700)
// .repeat(-1)
.playOn(button)
} I guess that a way fixto fix that would be to change the way Yoyo handles repetitions : |
@Lakedaemon Thanks for your information. I'll do some research on this issue, It's actually pretty annoying that the AnimatorSet has been set to final class descriptor... I have no idea why the made that. |
It seems that we could not use AnimatorSet.clone() method. I have an idea, we can setRepeatCount for each ValueAnimator which in AnimatorSet. Then play together will work as we expected. |
一样还是崩溃!为啥不修复好可惜的一个项目没法用了 |
I have this problem too in android 4.4 |
With repeat 1 the problem not appear.. |
Hi guys, sorry for my late reply, there was something terrible happened to my family two month ago, so I disappeared for a while. Anyway, This issue has been fixed, new version will be published to maven ASAP. Thanks @Tinker-S . |
could you tell me how to fix ? |
i have download your demo,and run it ,but when i touch one list item,it is broken.and show the NullPointerException . i found if i set repeat 1,it is ok,but if i set others ,it is broken.
The text was updated successfully, but these errors were encountered: