I have the following animated vector drawable:
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_ventilation" >
<target
android:name="fan_group"
android:animation="@animator/fan_rotation_animation" />
</animated-vector>
It just animated a fan using a rotation animation.
I am setting this icon in an ImageView
and controlling the start/stop animation calling the following method (nnly in Lollipop and high):
public void setStopped(boolean stopped) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.setImageResource(R.drawable.ic_ventilation_animated);
Drawable drawable = this.getDrawable();
if (drawable instanceof AnimatedVectorDrawableCompat) {
if(stopped) {
((AnimatedVectorDrawableCompat) drawable).stop();
} else {
((AnimatedVectorDrawableCompat) drawable).start();
}
}
}
}
But I get the following exception:
android.support.test.espresso.AppNotIdleException: Looped for 3654 iterations over 60 SECONDS. The following Idle Conditions failed .
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:580)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:88)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:51)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:173)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:114)
I have disabled animations in the developer options menu, like explained here.
With the animations disabled, I see that the icon doesn't animate anymore after calling ((AnimatedVectorDrawableCompat) drawable).start();
. However, the the exception is raised.
Is there a problem when calling the ((AnimatedVectorDrawableCompat) drawable).start();
method even when animations are disabled? How can I fix this so I can run my tests without need to care about the animation?