{"record":{"id":"9aa7f67c7ec3245b","repo":"material-components/material-components-android","slug":"indicatorcolors-cannot-be-empty-when-indicatorcolo","errorCode":null,"errorMessage":"indicatorColors cannot be empty when indicatorColor is not used.","messagePattern":"indicatorColors cannot be empty when indicatorColor is not used\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/loadingindicator/LoadingIndicatorSpec.java","lineNumber":109,"sourceCode":"          };\n      return;\n    }\n\n    TypedValue indicatorColorValue =\n        typedArray.peekValue(R.styleable.LoadingIndicator_indicatorColor);\n\n    if (indicatorColorValue.type != TypedValue.TYPE_REFERENCE) {\n      indicatorColors =\n          new int[] {typedArray.getColor(R.styleable.LoadingIndicator_indicatorColor, -1)};\n      return;\n    }\n\n    indicatorColors =\n        context\n            .getResources()\n            .getIntArray(typedArray.getResourceId(R.styleable.LoadingIndicator_indicatorColor, -1));\n    if (indicatorColors.length == 0) {\n      throw new IllegalArgumentException(\n          \"indicatorColors cannot be empty when indicatorColor is not used.\");\n    }\n  }\n\n  /**\n   * Sets the scale specs to fit the given bound of the {@link LoadingIndicatorDrawable}.\n   *\n   * @param scaleToFit The new scaleToFit value.\n   */\n  public void setScaleToFit(boolean scaleToFit){\n    this.scaleToFit = scaleToFit;\n  }\n}\n","sourceCodeStart":91,"sourceCodeEnd":123,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/loadingindicator/LoadingIndicatorSpec.java#L91-L123","documentation":"LoadingIndicatorSpec parses the indicatorColor attribute: when it points to a color everything is fine, but when it points to an array resource (@array/... via TYPE_REFERENCE) the array is read with getIntArray. An empty array resource leaves the indicator with no colors to draw, which is unrecoverable, so initialization throws IllegalArgumentException.","triggerScenarios":"Setting app:indicatorColor=\"@array/empty_colors\" (or any <integer-array> with zero items) on a LoadingIndicator (CircularProgressIndicator-style loading spinner styled with LoadingIndicator attributes); referencing an array resource that resolves to empty in some build variant/flavor.","commonSituations":"Shared color arrays defined per-flavor where one flavor ships an empty list; typos pointing at the wrong array resource; arrays built by resource merging that end up empty.","solutions":["Populate the referenced integer-array with at least one color: <integer-array name=\"indicator_colors\"><item>@color/blue</item></integer-array>.","Or point app:indicatorColor at a single color instead of an array reference.","Audit all build variants/flavors to ensure the array resource is non-empty everywhere it resolves."],"exampleFix":"<!-- before -->\n<integer-array name=\"indicator_colors\" />\n<com...LoadingIndicator app:indicatorColor=\"@array/indicator_colors\" ... />\n\n<!-- after -->\n<integer-array name=\"indicator_colors\">\n  <item>@color/m3_sys_color_primary</item>\n</integer-array>","handlingStrategy":"validation","validationCode":"int[] colors = context.getResources().getIntArray(R.array.indicator_colors);\nif (colors == null || colors.length == 0) {\n  colors = new int[] { ContextCompat.getColor(context, R.color.default_indicator) };\n}\n// then set programmatically instead of relying on the attribute","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep every integer-array referenced by app:indicatorColor non-empty in all flavors/build types.","Add a CI resource check or unit test asserting array length > 0.","Prefer a single color attribute unless multiple colors are genuinely needed."],"tags":["material-components","loading-indicator","resources","theming"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}