{"record":{"id":"a1e8c28a280813b3","repo":"material-components/material-components-android","slug":"stop-indicator-size-must-be-0","errorCode":null,"errorMessage":"Stop indicator size must be >= 0.","messagePattern":"Stop indicator size must be >= 0\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java","lineNumber":159,"sourceCode":"            : trackInnerCornerRadius;\n  }\n\n  @Px\n  int getActualTrackStopIndicatorSize() {\n    return min(trackStopIndicatorSize, trackThickness);\n  }\n\n  @Override\n  public boolean useStrokeCap() {\n    return super.useStrokeCap() && getTrackInnerCornerRadiusInPx() == getTrackCornerRadiusInPx();\n  }\n\n  @Override\n  void validateSpec() {\n    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    }","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/progressindicator/LinearProgressIndicatorSpec.java#L141-L177","documentation":"LinearProgressIndicatorSpec.validateSpec() throws IllegalArgumentException when trackStopIndicatorSize is negative. The stop indicator is the small dot drawn at the ends of a determinate linear track; a negative size has no valid visual meaning, so it is rejected during spec validation (which runs on inflation and on setter calls).","triggerScenarios":"Setting app:trackStopIndicatorSize=\"-4dp\" in XML, or calling setTrackStopIndicatorSize(-4) (or a trackStopIndicatorSize resource that resolves negative, e.g. a dimension computed at runtime), which triggers spec.validateSpec().","commonSituations":"Computing the stop indicator size from a dimension resource that flips negative on small screens or with inverted math; copying a style that uses -1 as a 'disabled' sentinel; refactoring a dimension arithmetic expression that underflows.","solutions":["Set the size to 0 to hide the stop indicator instead of a negative value.","Check the dimension resource / calculation feeding trackStopIndicatorSize and clamp it: Math.max(0, size).","Search the layout/style for app:trackStopIndicatorSize and fix any negative dp value."],"exampleFix":"<!-- before -->\n<com.google.android.material.progressindicator.LinearProgressIndicator\n    app:trackStopIndicatorSize=\"-2dp\" ... />\n\n<!-- after -->\n<com.google.android.material.progressindicator.LinearProgressIndicator\n    app:trackStopIndicatorSize=\"0dp\" ... />","handlingStrategy":"validation","validationCode":"int safeStopSize = Math.max(0, resolveDimension(context, R.dimen.stop_indicator));\nindicator.setTrackStopIndicatorSize(safeStopSize);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat negative dimension sentinels as invalid for Material progress specs; use 0dp to disable visuals.","LINT any computed dimensions passed into progress-indicator setters for negative clamping."],"tags":["android","material-components","progress-indicator","validation","xml"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}