{"record":{"id":"509841db66778cb5","repo":"material-components/material-components-android","slug":"endiconsize-cannot-be-less-than-0","errorCode":null,"errorMessage":"endIconSize cannot be less than 0","messagePattern":"endIconSize cannot be less than 0","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/textfield/EndCompoundLayout.java","lineNumber":577,"sourceCode":"  }\n\n  void setEndIconTintList(@Nullable ColorStateList endIconTintList) {\n    if (this.endIconTintList != endIconTintList) {\n      this.endIconTintList = endIconTintList;\n      applyIconTint(textInputLayout, endIconView, this.endIconTintList, endIconTintMode);\n    }\n  }\n\n  void setEndIconTintMode(@Nullable PorterDuff.Mode endIconTintMode) {\n    if (this.endIconTintMode != endIconTintMode) {\n      this.endIconTintMode = endIconTintMode;\n      applyIconTint(textInputLayout, endIconView, endIconTintList, this.endIconTintMode);\n    }\n  }\n\n  void setEndIconMinSize(@Px int iconSize) {\n    if (iconSize < 0) {\n      throw new IllegalArgumentException(\"endIconSize cannot be less than 0\");\n    }\n    if (iconSize != endIconMinSize) {\n      endIconMinSize = iconSize;\n      setIconMinSize(endIconView, iconSize);\n      setIconMinSize(errorIconView, iconSize);\n    }\n  }\n\n  int getEndIconMinSize() {\n    return endIconMinSize;\n  }\n\n  void setEndIconScaleType(@NonNull ScaleType endIconScaleType) {\n    this.endIconScaleType = endIconScaleType;\n    setIconScaleType(endIconView, endIconScaleType);\n    setIconScaleType(errorIconView, endIconScaleType);\n  }\n","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/textfield/EndCompoundLayout.java#L559-L595","documentation":"EndCompoundLayout.setEndIconMinSize validates that the minimum end-icon size is non-negative and applies it to the end icon and error icon views. A negative size has no valid meaning for view sizing, so it throws IllegalArgumentException immediately.","triggerScenarios":"Calling textInputLayout.setEndIconMinSize(negative) in code, or passing a negative dimension for app:endIconMinSize in XML.","commonSituations":"Computing icon size from a resource/variable that can be -1 (e.g. an unresolved dimension or an unselected sentinel); typos in dimens; mirroring an attribute value between start/end icons with a sign error.","solutions":["Pass a non-negative dimension: setEndIconMinSize(getResources().getDimensionPixelSize(R.dimen.icon_min)).","Treat -1/UNSPECIFIED sentinels as 'do not set' instead of forwarding them to the API.","Check app:endIconMinSize values in XML are positive dimensions."],"exampleFix":"// before\nint size = prefs.getInt(\"icon_min\", -1);\ntil.setEndIconMinSize(size); // -1 throws\n\n// after\nint size = prefs.getInt(\"icon_min\", 0);\nif (size >= 0) til.setEndIconMinSize(size);","handlingStrategy":"validation","validationCode":"if (iconMinSize >= 0) til.setEndIconMinSize(iconMinSize);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat -1/UNSPECIFIED sentinels as 'skip the call'.","Resolve sizes via getDimensionPixelSize, never raw ints from config.","Unit-test icon-size inputs for non-negativity."],"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"}