material-components/material-components-android · error · IllegalArgumentException
Cannot set framework drawable as indeterminate drawable.
Error message
Cannot set framework drawable as indeterminate drawable.
What it means
BaseProgressIndicator.setIndeterminateDrawable requires an IndeterminateDrawable once the indicator is initialized; anything else throws IllegalArgumentException because Material's indeterminate animation delegates drive the drawable and a framework drawable cannot participate. The uninitialized branch exists only for the super constructor path.
Source
Thrown at lib/java/com/google/android/material/progressindicator/BaseProgressIndicator.java:431
throw new IllegalArgumentException("Cannot set framework drawable as progress drawable.");
}
}
/**
* Sets a new indeterminate drawable. It has to inherit from {@link IndeterminateDrawable}.
*
* @param drawable The new indeterminate drawable.
* @throws IllegalArgumentException if a framework drawable is passed in.
*/
@Override
public void setIndeterminateDrawable(@Nullable Drawable drawable) {
if (drawable instanceof IndeterminateDrawable) {
((DrawableWithAnimatedVisibilityChange) drawable).hideNow();
super.setIndeterminateDrawable(drawable);
} else if (!initialized) {
super.setIndeterminateDrawable(drawable);
} else {
throw new IllegalArgumentException(
"Cannot set framework drawable as indeterminate drawable.");
}
}
@Nullable
@Override
public DeterminateDrawable<S> getProgressDrawable() {
return (DeterminateDrawable<S>) super.getProgressDrawable();
}
@Nullable
@Override
public IndeterminateDrawable<S> getIndeterminateDrawable() {
return (IndeterminateDrawable<S>) super.getIndeterminateDrawable();
}
/**
* Returns whether or not this view is currently displayed in window, based on whether it isView on GitHub (pinned to ac7e18efee)
Solutions
- Remove custom indeterminate drawables; configure indeterminate appearance via indicator attributes (indicatorColor, indeterminateAnimationType, etc.)
- If swapping drawables programmatically, only pass IndeterminateDrawable instances built for this indicator
- Fall back to a standard ProgressBar when a custom indeterminate drawable is mandatory
Example fix
<!-- before -->
<com.google.android.material.progressindicator.CircularProgressIndicator
android:indeterminateDrawable="@drawable/spin_animation" ... />
<!-- after -->
<com.google.android.material.progressindicator.CircularProgressIndicator
app:indicatorColor="@color/brand"
app:indeterminateAnimationType="contiguous" ... /> Defensive patterns
Strategy: type-guard
Type guard
fun isSafeIndeterminateDrawable(d: Drawable?): Boolean = d is IndeterminateDrawable
Try / catch
catch (e: IllegalArgumentException) { Log.e(TAG, "Rejected framework indeterminate drawable", e) } Prevention
- Configure indeterminate looks via attributes, not drawables
- Only pass IndeterminateDrawable instances created for this indicator
- Avoid porting android:indeterminateDrawable overrides from ProgressBar
When it happens
Trigger: Calling setIndeterminateDrawable(drawable) with a framework AnimationDrawable or custom Drawable on an initialized LinearProgressIndicator/CircularProgressIndicator.
Common situations: Reusing code that customized android:indeterminateDrawable on ProgressBar; XML android:indeterminateDrawable with a non-Material drawable on a Material indicator.
Related errors
- Cannot set framework drawable as progress drawable.
- The component's visibility must be one of VISIBLE, INVISIBLE
- indicatorColors cannot be empty when indicatorColor is not u
- indicatorTrackGapSize must be >= 0.
- Cannot change indeterminate animation type while the progres
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/297334ed778bd611.
Report an issue: GitHub.