{"record":{"id":"83b4c138a99f5443","repo":"material-components/material-components-android","slug":"indicatorcolors-cannot-be-empty-when-indicatorcolo-83b4c1","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/progressindicator/BaseProgressIndicatorSpec.java","lineNumber":225,"sourceCode":"      return;\n    }\n\n    TypedValue indicatorColorValue =\n        typedArray.peekValue(R.styleable.BaseProgressIndicator_indicatorColor);\n\n    if (indicatorColorValue.type != TypedValue.TYPE_REFERENCE) {\n      indicatorColors =\n          new int[] {typedArray.getColor(R.styleable.BaseProgressIndicator_indicatorColor, -1)};\n      return;\n    }\n\n    indicatorColors =\n        context\n            .getResources()\n            .getIntArray(\n                typedArray.getResourceId(R.styleable.BaseProgressIndicator_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   * Loads the trackColor from attributes if existing; otherwise, uses the first value in {@link\n   * BaseProgressIndicatorSpec#indicatorColors} applying the alpha value for disable items from\n   * theme. This method doesn't recycle the {@link TypedArray} argument.\n   *\n   * @param context The current active context.\n   * @param typedArray The TypedArray object of the attributes.\n   */\n  private void loadTrackColor(@NonNull Context context, @NonNull TypedArray typedArray) {\n    if (typedArray.hasValue(R.styleable.BaseProgressIndicator_trackColor)) {\n      trackColor = typedArray.getColor(R.styleable.BaseProgressIndicator_trackColor, -1);\n      return;\n    }\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/BaseProgressIndicatorSpec.java#L207-L243","documentation":"BaseProgressIndicatorSpec loads indicatorColor either as a single color or as an array resource (TYPE_REFERENCE). When the attribute is a reference to an array resource that is empty (zero entries), it throws IllegalArgumentException, since an indicator with no colors cannot render any stroke.","triggerScenarios":"Setting app:indicatorColor=\"@array/empty_colors\" (an <integer-array> or similar with no <item> entries) on LinearProgressIndicator/CircularProgressIndicator; the TypedValue is TYPE_REFERENCE, getIntArray returns length 0, and the guard throws.","commonSituations":"Colors array generated from a build config or remote config that ends up empty; placeholder array resource left empty; wrong resource linked (points at an empty array).","solutions":["Populate the color array with at least one entry","If a single color is intended, set app:indicatorColor=\"@color/x\" directly instead of an array reference","Add a resource-level sanity check for generated color arrays (fail build when empty)"],"exampleFix":"<!-- before: res/values/arrays.xml -->\n<integer-array name=\"progress_colors\"/>\n<!-- after -->\n<integer-array name=\"progress_colors\">\n  <item>@color/brand_primary</item>\n  <item>@color/brand_secondary</item>\n</integer-array>","handlingStrategy":"validation","validationCode":"fun hasNonEmptyColorArray(context: Context, arrayRes: Int): Boolean {\n    val arr = context.resources.getIntArray(arrayRes)\n    return arr.isNotEmpty()\n}","typeGuard":null,"tryCatchPattern":"catch (e: IllegalArgumentException) { Log.e(TAG, \"indicatorColor array empty; using single color\", e); setSingleIndicatorColor() }","preventionTips":["Ensure every color array resource has at least one entry","Prefer a single @color when only one color is needed","Assert generated arrays are non-empty in build checks"],"tags":["android","material-components","progressindicator","color","resources"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}