{"record":{"id":"2d995a5bebc8629d","repo":"material-components/material-components-android","slug":"starticonsize-cannot-be-less-than-0","errorCode":null,"errorMessage":"startIconSize cannot be less than 0","messagePattern":"startIconSize cannot be less than 0","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/textfield/StartCompoundLayout.java","lineNumber":294,"sourceCode":"  }\n\n  void setStartIconTintList(@Nullable ColorStateList startIconTintList) {\n    if (this.startIconTintList != startIconTintList) {\n      this.startIconTintList = startIconTintList;\n      applyIconTint(textInputLayout, startIconView, startIconTintList, startIconTintMode);\n    }\n  }\n\n  void setStartIconTintMode(@Nullable PorterDuff.Mode startIconTintMode) {\n    if (this.startIconTintMode != startIconTintMode) {\n      this.startIconTintMode = startIconTintMode;\n      applyIconTint(textInputLayout, startIconView, startIconTintList, this.startIconTintMode);\n    }\n  }\n\n  void setStartIconMinSize(@Px int iconSize) {\n    if (iconSize < 0) {\n      throw new IllegalArgumentException(\"startIconSize cannot be less than 0\");\n    }\n    if (iconSize != startIconMinSize) {\n      startIconMinSize = iconSize;\n      setIconMinSize(startIconView, iconSize);\n    }\n  }\n\n  int getStartIconMinSize() {\n    return startIconMinSize;\n  }\n\n  void setStartIconScaleType(@NonNull ScaleType startIconScaleType) {\n    this.startIconScaleType = startIconScaleType;\n    setIconScaleType(startIconView, startIconScaleType);\n  }\n\n  @NonNull\n  ScaleType getStartIconScaleType() {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/textfield/StartCompoundLayout.java#L276-L312","documentation":"StartCompoundLayout.setStartIconMinSize validates that the minimum start-icon size is non-negative before applying it to the start icon view. Negative sizes are meaningless for view layout, so it throws IllegalArgumentException('startIconSize cannot be less than 0').","triggerScenarios":"Calling setStartIconMinSize(-1) or any negative value; negative app:startIconMinSize dimension in XML.","commonSituations":"Sentinel -1 from unresolved settings or unselected config forwarded directly; dimension arithmetic that underflows; copy-paste between icon-size attributes with a sign mistake.","solutions":["Pass a non-negative pixel size: setStartIconMinSize(getResources().getDimensionPixelSize(R.dimen.icon_min)).","Guard config-driven values: only call the setter when size >= 0.","Review app:startIconMinSize dimens for typos."],"exampleFix":"// before\ntil.setStartIconMinSize(iconSize); // iconSize == -1 sentinel -> throws\n\n// after\nif (iconSize >= 0) til.setStartIconMinSize(iconSize);","handlingStrategy":"validation","validationCode":"if (iconMinSize >= 0) til.setStartIconMinSize(iconMinSize);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard config-driven sizes with >= 0 checks.","Use dimension resources for icon sizes instead of computed raw ints.","Share one validated size constant for start and end icons."],"tags":["textinputlayout","validation","icons","android"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}