{"record":{"id":"94b6f21a22628d99","repo":"material-components/material-components-android","slug":"minseparation-s-must-be-greater-or-equal-and-a-m","errorCode":null,"errorMessage":"minSeparation(%s) must be greater or equal and a multiple of stepSize(%s) when using stepSize(%s)","messagePattern":"minSeparation\\((.+?)\\) must be greater or equal and a multiple of stepSize\\((.+?)\\) when using stepSize\\((.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":768,"sourceCode":"            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) {\n      Log.w(TAG, String.format(WARNING_FLOATING_POINT_ERROR, \"stepSize\", stepSize));\n    }\n\n    if ((int) valueFrom != valueFrom) {\n      Log.w(TAG, String.format(WARNING_FLOATING_POINT_ERROR, \"valueFrom\", valueFrom));","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L750-L786","documentation":"Thrown by validateMinSeparation() in discrete mode when minSeparation (in value units) is smaller than stepSize or is not an exact multiple of stepSize. Since thumbs snap to ticks, a separation that does not align with ticks cannot be enforced, so the combination is rejected at layout time.","triggerScenarios":"stepSize > 0 and minSeparation > 0 with minSeparation < stepSize (e.g. stepSize=5, minSeparation=3), or minSeparation not a multiple (e.g. stepSize=5, minSeparation=7).","commonSituations":"Design specs asking for 'thumbs at least 3 apart' on a slider with stepSize 5; reusing minSeparation values after increasing stepSize.","solutions":["Round minSeparation up to the next multiple of stepSize: ((int)(minSep / step) + 1) * step when there is a remainder.","At minimum use minSeparation = stepSize.","If exact separation matters more than snapping, drop stepSize and use continuous mode.","Recompute separation whenever stepSize changes."],"exampleFix":"// before\nslider.setStepSize(5f);\nslider.setMinSeparation(3f); // 3 < 5 and not a multiple -> throws\n\n// after\nslider.setStepSize(5f);\nslider.setMinSeparation(5f); // equal to and a multiple of stepSize","handlingStrategy":"validation","validationCode":"static float alignSeparationToStep(float minSep, float step) {\n  if (step <= 0f) return minSep;\n  float k = (float) Math.ceil(minSep / step);\n  return k * step; // >= step and an exact multiple\n}\nslider.setMinSeparation(alignSeparationToStep(3f, 5f)); // -> 5f","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Recompute separation whenever stepSize changes.","Prefer separations expressed as N * stepSize in design specs."],"tags":["android","slider","material-components","configuration","range-slider"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}