{"record":{"id":"4dac6d0919b88f47","repo":"material-components/material-components-android","slug":"slider-value-s-must-be-greater-or-equal-to-value","errorCode":null,"errorMessage":"Slider value(%s) must be greater or equal to valueFrom(%s), and lower or equal to valueTo(%s)","messagePattern":"Slider value\\((.+?)\\) must be greater or equal to valueFrom\\((.+?)\\), and lower or equal to valueTo\\((.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":749,"sourceCode":"    if (stepSize > 0.0f && !valueLandsOnTick(valueTo)) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_STEP_SIZE, stepSize, valueFrom, valueTo));\n    }\n  }\n\n  private void validateValues() {\n    if (valueFrom >= valueTo) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_VALUE_FROM, valueFrom, valueTo));\n    }\n\n    for (Float value : values) {\n      if (value < valueFrom || value > valueTo) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_VALUE, value, valueFrom, valueTo));\n      }\n      if (stepSize > 0.0f && !valueLandsOnTick(value)) {\n        throw new IllegalStateException(\n            String.format(EXCEPTION_ILLEGAL_DISCRETE_VALUE, value, valueFrom, stepSize, stepSize));\n      }\n    }\n  }\n\n  private void validateMinSeparation() {\n    final float minSeparation = getMinSeparation();\n    if (minSeparation < 0) {\n      throw new IllegalStateException(\n          String.format(EXCEPTION_ILLEGAL_MIN_SEPARATION, minSeparation));\n    }\n    if (stepSize > 0 && minSeparation > 0) {\n      if (separationUnit != UNIT_VALUE) {\n        throw new IllegalStateException(\n            String.format(\n                EXCEPTION_ILLEGAL_MIN_SEPARATION_STEP_SIZE_UNIT, minSeparation, stepSize));\n      }\n      if (minSeparation < stepSize || !isMultipleOfStepSize(minSeparation)) {","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L731-L767","documentation":"Thrown by validateValues() when any of the slider's current values (each thumb's position) falls outside [valueFrom, valueTo]. This commonly happens after shrinking the range while old values are still set, or after setValues() with values beyond the bounds. The message includes the offending value, valueFrom, and valueTo.","triggerScenarios":"Calling setValues(...) with a value outside the range; calling setValueFrom/setValueTo to narrow the range while existing values (set earlier or from XML android:value) are now outside it; restoring state (onRestoreInstanceState) into a view whose range changed.","commonSituations":"Persisting the slider value (e.g. in SharedPreferences) and restoring it after the range was changed in a new app version; filtering UIs where the max price range shrinks based on another filter but the previous selection is kept.","solutions":["Re-apply values with Math.max(valueFrom, Math.min(valueTo, value)) after changing the range.","Set the range (valueFrom/valueTo/stepSize) before setting values.","When restoring persisted values, clamp them to the current range before calling setValues().","Verify every value in a multi-thumb list is within bounds and sorted is handled internally, but bounds are your job."],"exampleFix":"// before\nslider.setValueFrom(0f);\nslider.setValueTo(5f);\nslider.setValues(7f); // 7 > valueTo -> crash on layout\n\n// after\nslider.setValueFrom(0f);\nslider.setValueTo(10f);\nslider.setValues(7f);","handlingStrategy":"validation","validationCode":"static float clampToRange(float v, Slider slider) {\n  return Math.max(slider.getValueFrom(), Math.min(slider.getValueTo(), v));\n}\n// slider.setValues(clampToRange(savedValue, slider));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set range first, values second.","Clamp any persisted/restored value to the current range before applying.","Re-clamp values whenever the range changes at runtime."],"tags":["android","slider","material-components","configuration","layout-time"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}