{"record":{"id":"585f2217c8baa0ee","repo":"material-components/material-components-android","slug":"minseparation-s-cannot-be-set-as-a-dimension-whe","errorCode":null,"errorMessage":"minSeparation(%s) cannot be set as a dimension when using stepSize(%s)","messagePattern":"minSeparation\\((.+?)\\) cannot be set as a dimension when using stepSize\\((.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":763,"sourceCode":"        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)) {\n        throw new IllegalStateException(\n            String.format(\n                EXCEPTION_ILLEGAL_MIN_SEPARATION_STEP_SIZE, minSeparation, stepSize, stepSize));\n      }\n    }\n  }\n\n  private void warnAboutFloatingPointError() {\n    if (stepSize == 0) {\n      // Only warn if slider uses a step value.\n      return;\n    }\n\n    if ((int) stepSize != stepSize) {","sourceCodeStart":745,"sourceCodeEnd":781,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L745-L781","documentation":"Thrown by validateMinSeparation() when a dimension-based min separation (setMinSeparationDimension / separationUnit != UNIT_VALUE) is combined with a positive stepSize. In discrete mode ticks are value-based, so a pixel/dp separation cannot be reconciled with value steps, and the library rejects the combination at layout time.","triggerScenarios":"Calling setMinSeparationDimension(ratioOrDimension) (or setting app:minSeparation as a dimension) on a slider that also has stepSize > 0.","commonSituations":"Reusing a range-slider styling block (with dp-based minSeparation) on a slider that was later switched to discrete ticks; XML copied from a continuous slider template into a discrete one.","solutions":["Use setMinSeparation(value) (UNIT_VALUE) instead of the dimension variant when stepSize > 0.","Or remove stepSize (set it to 0) if the dimension-based separation must be kept.","Pick a value-unit separation that is >= stepSize and a multiple of it (see error 145)."],"exampleFix":"// before\nslider.setStepSize(1f);\nslider.setMinSeparationDimension(16f, SliderSeparationUnit.PIXEL); // throws on layout\n\n// after\nslider.setStepSize(1f);\nslider.setMinSeparation(2f); // value units, multiple of stepSize","handlingStrategy":"validation","validationCode":"if (slider.getStepSize() > 0f) {\n  slider.setMinSeparation(2f);          // value units\n} else {\n  slider.setMinSeparationDimension(dp, SliderSeparationUnit.DP);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a single slider-configuration helper so stepSize and separation unit cannot diverge.","Remember: discrete mode forces value-unit separation."],"tags":["android","slider","material-components","configuration","range-slider"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}