material-components/material-components-android · error · IllegalArgumentException
Cannot set showAnimator while the current showAnimator is ru
Error message
Cannot set showAnimator while the current showAnimator is running.
What it means
DrawableWithAnimatedVisibilityChange.setShowAnimator throws IllegalArgumentException if a replacement show animator is set while the current show animator is still running. Swapping an in-flight animator would orphan listeners and animation state, so the setter refuses until the running animation ends.
Source
Thrown at lib/java/com/google/android/material/progressindicator/DrawableWithAnimatedVisibilityChange.java:367
public void setColorFilter(@Nullable ColorFilter colorFilter) {
paint.setColorFilter(colorFilter);
invalidateSelf();
}
@Override
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
/**
* Sets a value animator for show animation. This only takes effect when the drawable is not
* currently being shown.
*
* @param showAnimator A ValueAnimator used for show animation.
*/
private void setShowAnimator(@NonNull ValueAnimator showAnimator) {
if (this.showAnimator != null && this.showAnimator.isRunning()) {
throw new IllegalArgumentException(
"Cannot set showAnimator while the current showAnimator is running.");
}
this.showAnimator = showAnimator;
// Adds a listener to dispatch animation callbacks at the end.
showAnimator.addListener(
new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
dispatchAnimationStart();
}
});
}
@NonNull
ValueAnimator getHideAnimator() {View on GitHub (pinned to ac7e18efee)
Solutions
- Wait for the current show animation to end (listen for animation end) before replacing the animator
- Cancel the running animator first, then set the new one
- Set custom animators once during setup, before any show/hide animation can run
Example fix
// before indicator.show() indicator.getIndeterminateDrawable().setShowAnimator(newAnimator) // throws while running // after indicator.hide() indicator.getIndeterminateDrawable().setShowAnimator(newAnimator) indicator.show()
Defensive patterns
Strategy: validation
Validate before calling
fun replaceShowAnimator(drawable: DrawableWithAnimatedVisibilityChange, animator: ValueAnimator) {
drawable.hideNow() // ensure not mid-show
drawable.setShowAnimator(animator)
} Try / catch
catch (e: IllegalArgumentException) { Log.w(TAG, "Show animator running; deferring swap to animation end", e); deferSwapUntilAnimationEnd() } Prevention
- Install custom show/hide animators once during initialization
- Never swap animators while animations are running
- Listen for animation end before replacing animators
When it happens
Trigger: Calling a method that replaces the show animator (e.g. mutating showAnimator on the drawable/indicator while it is mid show-animation); typically via custom animation injection right after show() was called.
Common situations: Customizing show/hide animators on a progress indicator drawable in response to config changes while the indicator is animating in; rapid successive API calls before the previous animation finished.
Related errors
- Cannot set hideAnimator while the current hideAnimator is ru
- Cannot change indeterminate animation type while the progres
- Cannot change indeterminate animation type while the progres
- Keylines being linearly interpolated must have the same item
- Keylines being linearly interpolated must have the same numb
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/a2019a8699edd49b.
Report an issue: GitHub.