{"record":{"id":"fbfbbb9b4a555bb3","repo":"material-components/material-components-android","slug":"cannot-set-hideanimator-while-the-current-hideanim","errorCode":null,"errorMessage":"Cannot set hideAnimator while the current hideAnimator is running.","messagePattern":"Cannot set hideAnimator while the current hideAnimator is running\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/progressindicator/DrawableWithAnimatedVisibilityChange.java","lineNumber":397,"sourceCode":"            dispatchAnimationStart();\n          }\n        });\n  }\n\n  @NonNull\n  ValueAnimator getHideAnimator() {\n    return hideAnimator;\n  }\n\n  /**\n   * Sets a value animator for hide animation. This only takes effect when the drawable is not\n   * currently being hidden.\n   *\n   * @param hideAnimator A ValueAnimator used for hide animation.\n   */\n  private void setHideAnimator(@NonNull ValueAnimator hideAnimator) {\n    if (this.hideAnimator != null && this.hideAnimator.isRunning()) {\n      throw new IllegalArgumentException(\n          \"Cannot set hideAnimator while the current hideAnimator is running.\");\n    }\n\n    this.hideAnimator = hideAnimator;\n\n    // Adds a listener to set visibility false and dispatch animation callbacks at the end.\n    hideAnimator.addListener(\n        new AnimatorListenerAdapter() {\n          @Override\n          public void onAnimationEnd(Animator animation) {\n            super.onAnimationEnd(animation);\n            // Sets visibility to false.\n            DrawableWithAnimatedVisibilityChange.super.setVisible(false, DEFAULT_DRAWABLE_RESTART);\n\n            dispatchAnimationEnd();\n          }\n        });\n  }","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/DrawableWithAnimatedVisibilityChange.java#L379-L415","documentation":"DrawableWithAnimatedVisibilityChange.setHideAnimator throws IllegalArgumentException if the current hide animator is running when a replacement is set. The running animator's listeners drive visibility and callback dispatch, so replacing it mid-hide would break the hide lifecycle; the setter requires the previous hide animation to be finished.","triggerScenarios":"Replacing the hide animator while a hide animation is in flight — e.g. calling hide() then immediately updating the hide animator, or re-triggering hide on an already-hiding indicator whose animator is being swapped.","commonSituations":"Dynamically changing hide animations (duration/interpolator) in response to user actions while an indicator is dismissing; teardown code that mutates animators during fragment exit transitions.","solutions":["Only set the hide animator when no hide animation is running (check hideAnimator.isRunning() first if accessible, or await onAnimationEnd)","Configure hide animators once at init time","Cancel the in-flight hide animation before swapping animators"],"exampleFix":"// before\nindicator.hide()\ndrawable.setHideAnimator(newHideAnimator) // may throw mid-hide\n// after\n// wait for hide to complete (animation end callback), then:\ndrawable.setHideAnimator(newHideAnimator)","handlingStrategy":"validation","validationCode":"fun replaceHideAnimatorWhenIdle(drawable: DrawableWithAnimatedVisibilityChange, animator: ValueAnimator, onIdle: () -> Unit) {\n    val current = drawable.hideAnimator\n    if (current?.isRunning == true) {\n        current.addListener(object : AnimatorListenerAdapter() {\n            override fun onAnimationEnd(animation: Animator) { drawable.setHideAnimator(animator) }\n        })\n    } else {\n        drawable.setHideAnimator(animator)\n    }\n    onIdle()\n}","typeGuard":null,"tryCatchPattern":"catch (e: IllegalArgumentException) { Log.w(TAG, \"Hide animator running; will swap after end\", e); scheduleSwapAfterHideEnds() }","preventionTips":["Configure hide animators at init, not at runtime","Await onAnimationEnd before replacing animators","Avoid rapid successive show/hide customizations"],"tags":["android","material-components","progressindicator","animation","animator","state"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}