material-components/material-components-android · error · IllegalArgumentException

Rounded corners without gap are not supported in contiguous

Error message

Rounded corners without gap are not supported in contiguous indeterminate animation.

What it means

LinearProgressIndicatorSpec.validateSpec() throws when the contiguous indeterminate animation type is combined with rounded corners (track or indicator corner radius > 0) and indicatorTrackGapSize == 0. The contiguous animator moves seamlessly-joined segments, and rounded corners without a gap between the joined lines produce an invalid/incorrect rendering, so the spec is rejected up front.

Source

Thrown at lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java:168

  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

  1. Set a positive gap: app:indicatorTrackGapSize="4dp" (or setIndicatorTrackGapSize(4)) so rounded corners are supported.
  2. Or remove the corner radii: set app:trackCornerRadius and app:trackInnerCornerRadius to 0dp.
  3. Or keep the default disjoint animation type (INDETERMINATE_ANIMATION_TYPE_DISJOINT), which supports rounded corners without a gap.

Example fix

<!-- before -->
<com.google.android.material.progressindicator.LinearProgressIndicator
    app:indeterminateAnimationType="contiguous"
    app:trackCornerRadius="4dp" ... />

<!-- after -->
<com.google.android.material.progressindicator.LinearProgressIndicator
    app:indeterminateAnimationType="contiguous"
    app:trackCornerRadius="4dp"
    app:indicatorTrackGapSize="4dp" ... />
Defensive patterns

Strategy: validation

Validate before calling

// Before enabling contiguous type, ensure gap if corners are set
if (type == INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS
    && (trackCornerRadiusPx > 0 || indicatorTrackGapSizePx == 0)) {
  indicator.setIndicatorTrackGapSize(dp(4));
}

Prevention

When it happens

Trigger: Using INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS with app:trackCornerRadius (or app:trackInnerCornerRadius) > 0 while app:indicatorTrackGapSize is 0 or unset — via XML attributes or the corresponding runtime setters that call validateSpec().

Common situations: Enabling the Material 3-style contiguous animation on a themed indicator whose shape theme already applies trackCornerRadius; upgrading Material library version and switching animation type while keeping existing corner-radius attributes; copying a rounded-track style from a disjoint setup.

Related errors


AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14). Data as JSON: /api/errors/52a2412b28aaf61f. Report an issue: GitHub.