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

Contiguous indeterminate animation must be used with 3 or mo

Error message

Contiguous indeterminate animation must be used with 3 or more indicator colors.

What it means

LinearProgressIndicatorSpec.validateSpec() throws when the contiguous indeterminate animation type is selected but fewer than 3 indicator colors are configured. The contiguous animator renders three line segments that move as one unit, each needing its own color, so a 1- or 2-color palette is an invalid spec.

Source

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

    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. Provide at least 3 indicator colors: app:indicatorColors="@array/myThreeColors" where the array has >= 3 entries.
  2. Or unset/extend the color customization so the default 3-color Material3 palette applies.
  3. Or use the disjoint animation type if only 1-2 colors are wanted.

Example fix

<!-- before -->
<com.google.android.material.progressindicator.LinearProgressIndicator
    app:indeterminateAnimationType="contiguous"
    app:indicatorColors="@array/brandColors" /> <!-- 1 color -->

<!-- after -->
<integer-array name="brandColors">
    <item>@color/brand1</item>
    <item>@color/brand2</item>
    <item>@color/brand3</item>
</integer-array>
<com.google.android.material.progressindicator.LinearProgressIndicator
    app:indeterminateAnimationType="contiguous"
    app:indicatorColors="@array/brandColors" />
Defensive patterns

Strategy: validation

Validate before calling

int[] colors = getResources().getIntArray(R.array.brandIndicatorColors);
if (colors.length >= 3) {
  indicator.setIndeterminateColors(ColorStateList.valueOf(0));
  indicator.setIndicatorColors(colors);
  indicator.setIndeterminateAnimationType(LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS);
} else {
  indicator.setIndeterminateAnimationType(LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_DISJOINT);
}

Prevention

When it happens

Trigger: Setting app:indeterminateAnimationType="contiguous" while indicatorColors has length < 3 — e.g. relying on a theme default of one color, or setting app:indicatorColors with only one or two entries, or clearing colors at runtime before switching type.

Common situations: Applying the contiguous type to a branded indicator that overrides indicatorColors with a single brand color; inheriting a theme where colorPrimary is the only indicator color; reusing an old disjoint-style layout with the new animation type after a Material library upgrade.

Related errors


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