material-components/material-components-android · error · IllegalArgumentException
Stop indicator size must be >= 0.
Error message
Stop indicator size must be >= 0.
What it means
LinearProgressIndicatorSpec.validateSpec() throws IllegalArgumentException when trackStopIndicatorSize is negative. The stop indicator is the small dot drawn at the ends of a determinate linear track; a negative size has no valid visual meaning, so it is rejected during spec validation (which runs on inflation and on setter calls).
Source
Thrown at lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java:159
: trackInnerCornerRadius;
}
@Px
int getActualTrackStopIndicatorSize() {
return min(trackStopIndicatorSize, trackThickness);
}
@Override
public boolean useStrokeCap() {
return super.useStrokeCap() && getTrackInnerCornerRadiusInPx() == getTrackCornerRadiusInPx();
}
@Override
void validateSpec() {
super.validateSpec();
if (trackStopIndicatorSize < 0) {
// Throws an exception if trying to use a negative stop indicator size.
throw new IllegalArgumentException("Stop indicator size must be >= 0.");
}
if (indeterminateAnimationType
== LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS) {
if ((getTrackCornerRadiusInPx() > 0
|| (hasInnerCornerRadius && getTrackInnerCornerRadiusInPx() > 0))
&& indicatorTrackGapSize == 0) {
// Throws an exception if trying to use the cornered indicator/track with contiguous
// indeterminate animation type without gap.
throw new IllegalArgumentException(
"Rounded corners without gap are not supported in contiguous indeterminate animation.");
}
if (indicatorColors.length < 3) {
// Throws an exception if trying to set contiguous indeterminate animation with less than 3
// indicator colors.
throw new IllegalArgumentException(
"Contiguous indeterminate animation must be used with 3 or more indicator colors.");
}
}View on GitHub (pinned to ac7e18efee)
Solutions
- Set the size to 0 to hide the stop indicator instead of a negative value.
- Check the dimension resource / calculation feeding trackStopIndicatorSize and clamp it: Math.max(0, size).
- Search the layout/style for app:trackStopIndicatorSize and fix any negative dp value.
Example fix
<!-- before -->
<com.google.android.material.progressindicator.LinearProgressIndicator
app:trackStopIndicatorSize="-2dp" ... />
<!-- after -->
<com.google.android.material.progressindicator.LinearProgressIndicator
app:trackStopIndicatorSize="0dp" ... /> Defensive patterns
Strategy: validation
Validate before calling
int safeStopSize = Math.max(0, resolveDimension(context, R.dimen.stop_indicator)); indicator.setTrackStopIndicatorSize(safeStopSize);
Prevention
- Treat negative dimension sentinels as invalid for Material progress specs; use 0dp to disable visuals.
- LINT any computed dimensions passed into progress-indicator setters for negative clamping.
When it happens
Trigger: Setting app:trackStopIndicatorSize="-4dp" in XML, or calling setTrackStopIndicatorSize(-4) (or a trackStopIndicatorSize resource that resolves negative, e.g. a dimension computed at runtime), which triggers spec.validateSpec().
Common situations: Computing the stop indicator size from a dimension resource that flips negative on small screens or with inverted math; copying a style that uses -1 as a 'disabled' sentinel; refactoring a dimension arithmetic expression that underflows.
Related errors
- Rounded corners without gap are not supported in contiguous
- There must be a keyline marked as focal.
- No color resources provided for harmonization.
- Theme overlay should be used with the accompanying int[] att
- start Month cannot be after current Month
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/a1e8c28a280813b3.
Report an issue: GitHub.