Search code examples
androidanimatedvectordrawable

Animated Vector Drawable randomly completing instantly


I am using an AnimatedVectorDrawable in my app and it was working on 1 device, until suddenly it started completing instantly, without any changes from me. I invalidated caches and restarted Android Studio, I resynced my gradle, I deleted the cache of the app, then the entire app, then restarted my phone and still nothing. If I install the same code on a different device with the same OS as the device that it's completing on instantly, my animation works. (But it randomly stopped again, so I had to try yet ANOTHER device, where it works) Once it starts finishing the animation instantly on some devices, I can't get it to stop anymore.

Has anyone else had this problem?

I have the drawable repeating so this is how I set it up:

avdb = AnimatedVectorDrawableCompat.create(requireContext(), R.drawable.avd_anim)!!
binding.background.setImageDrawable(avdb)
avdb.start()
avdb.registerAnimationCallback(AnimationRestartCallback(requireContext(), binding.background))

the restart doesn't matter because not even the original animation will run once it stops running.


Solution

  • Silly me. I should start using the rubber ducky trick and explain my problem to it before I write to stack overflow. But at least maybe this will help someone.

    Check your developer options settings. You can force skip animations thanks to some animation settings there. That was my issue. Turned developer options off and everything worked as intended.