{"record":{"id":"4b288ce505f1ab9b","repo":"material-components/material-components-android","slug":"contiguous-indeterminate-animation-must-be-used-wi","errorCode":null,"errorMessage":"Contiguous indeterminate animation must be used with 3 or more indicator colors.","messagePattern":"Contiguous indeterminate animation must be used with 3 or more indicator colors\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java","lineNumber":174,"sourceCode":"    super.validateSpec();\n    if (trackStopIndicatorSize < 0) {\n      // Throws an exception if trying to use a negative stop indicator size.\n      throw new IllegalArgumentException(\"Stop indicator size must be >= 0.\");\n    }\n    if (indeterminateAnimationType\n        == LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS) {\n      if ((getTrackCornerRadiusInPx() > 0\n              || (hasInnerCornerRadius && getTrackInnerCornerRadiusInPx() > 0))\n          && indicatorTrackGapSize == 0) {\n        // Throws an exception if trying to use the cornered indicator/track with contiguous\n        // indeterminate animation type without gap.\n        throw new IllegalArgumentException(\n            \"Rounded corners without gap are not supported in contiguous indeterminate animation.\");\n      }\n      if (indicatorColors.length < 3) {\n        // Throws an exception if trying to set contiguous indeterminate animation with less than 3\n        // indicator colors.\n        throw new IllegalArgumentException(\n            \"Contiguous indeterminate animation must be used with 3 or more indicator colors.\");\n      }\n    }\n  }\n}\n","sourceCodeStart":156,"sourceCodeEnd":180,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java#L156-L180","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide at least 3 indicator colors: app:indicatorColors=\"@array/myThreeColors\" where the array has >= 3 entries.","Or unset/extend the color customization so the default 3-color Material3 palette applies.","Or use the disjoint animation type if only 1-2 colors are wanted."],"exampleFix":"<!-- before -->\n<com.google.android.material.progressindicator.LinearProgressIndicator\n    app:indeterminateAnimationType=\"contiguous\"\n    app:indicatorColors=\"@array/brandColors\" /> <!-- 1 color -->\n\n<!-- after -->\n<integer-array name=\"brandColors\">\n    <item>@color/brand1</item>\n    <item>@color/brand2</item>\n    <item>@color/brand3</item>\n</integer-array>\n<com.google.android.material.progressindicator.LinearProgressIndicator\n    app:indeterminateAnimationType=\"contiguous\"\n    app:indicatorColors=\"@array/brandColors\" />","handlingStrategy":"validation","validationCode":"int[] colors = getResources().getIntArray(R.array.brandIndicatorColors);\nif (colors.length >= 3) {\n  indicator.setIndeterminateColors(ColorStateList.valueOf(0));\n  indicator.setIndicatorColors(colors);\n  indicator.setIndeterminateAnimationType(LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_CONTIGUOUS);\n} else {\n  indicator.setIndeterminateAnimationType(LinearProgressIndicator.INDETERMINATE_ANIMATION_TYPE_DISJOINT);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Define the contiguous palette as a 3+ entry array resource and reference it, never individual colors.","When theming indicatorColors, verify the array length before choosing contiguous animation."],"tags":["android","material-components","progress-indicator","animation","colors"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}