{"record":{"id":"014d6bba22f00f39","repo":"material-components/material-components-android","slug":"unexpected-tickvisibilitymode","errorCode":null,"errorMessage":"Unexpected tickVisibilityMode: ","messagePattern":"Unexpected tickVisibilityMode: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/slider/BaseSlider.java","lineNumber":1938,"sourceCode":"    inactiveTicksPaint.setColor(getColorForState(tickColorInactive));\n    invalidate();\n  }\n\n  /**\n   * Returns whether the tick marks are visible. Only used when the slider is in discrete mode.\n   *\n   * @attr ref com.google.android.material.R.styleable#Slider_tickVisible\n   */\n  public boolean isTickVisible() {\n    switch (tickVisibilityMode) {\n      case TICK_VISIBILITY_AUTO_LIMIT:\n        return true;\n      case TICK_VISIBILITY_AUTO_HIDE:\n        return getDesiredTickCount() <= getMaxTickCount();\n      case TICK_VISIBILITY_HIDDEN:\n        return false;\n      default:\n        throw new IllegalStateException(\"Unexpected tickVisibilityMode: \" + tickVisibilityMode);\n    }\n  }\n\n  /**\n   * Sets whether the tick marks are visible. Only used when the slider is in discrete mode.\n   *\n   * @param tickVisible The visibility of tick marks.\n   * @attr ref com.google.android.material.R.styleable#Slider_tickVisible\n   * @deprecated Use {@link #setTickVisibilityMode(int)} instead.\n   */\n  @Deprecated\n  public void setTickVisible(boolean tickVisible) {\n    setTickVisibilityMode(convertToTickVisibilityMode(tickVisible));\n  }\n\n  @TickVisibilityMode\n  private int convertToTickVisibilityMode(boolean tickVisible) {\n    return tickVisible ? TICK_VISIBILITY_AUTO_LIMIT : TICK_VISIBILITY_HIDDEN;","sourceCodeStart":1920,"sourceCodeEnd":1956,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/slider/BaseSlider.java#L1920-L1956","documentation":"IllegalStateException thrown by isTickVisible() when tickVisibilityMode holds a value outside the known set (TICK_VISIBILITY_AUTO_LIMIT, AUTO_HIDE, HIDDEN). This is the switch's default arm; in normal operation the constants are @IntDef-annotated, so reaching it means an unannotated int was forced into the mode.","triggerScenarios":"Calling setTickVisibilityMode(rawInt) with an int not in the IntDef set (e.g. from a bundle, deep link parameter, or prefs) then invoking isTickVisible(); reflection or cross-version constant mismatches after downgrading the library.","commonSituations":"Persisting the visibility mode as an int and restoring it after a library downgrade where constant values shifted; passing mode values through untyped channels (Intent extras, JSON).","solutions":["Only pass Slider.TICK_VISIBILITY_* constants to setTickVisibilityMode.","Validate restored ints against the known set before applying, defaulting to TICK_VISIBILITY_AUTO_HIDE.","Keep the annotation processor / lint IntDef checks enabled so bad ints are caught at compile time."],"exampleFix":"// before\nslider.setTickVisibilityMode(modeFromPrefs); // arbitrary int -> may throw later\n\n// after\nint mode = (modeFromPrefs == Slider.TICK_VISIBILITY_AUTO_LIMIT\n    || modeFromPrefs == Slider.TICK_VISIBILITY_AUTO_HIDE\n    || modeFromPrefs == Slider.TICK_VISIBILITY_HIDDEN)\n        ? modeFromPrefs : Slider.TICK_VISIBILITY_AUTO_HIDE;\nslider.setTickVisibilityMode(mode);","handlingStrategy":"validation","validationCode":"static boolean isValidTickVisibilityMode(int m) {\n  return m == Slider.TICK_VISIBILITY_AUTO_LIMIT\n      || m == Slider.TICK_VISIBILITY_AUTO_HIDE\n      || m == Slider.TICK_VISIBILITY_HIDDEN;\n}\nslider.setTickVisibilityMode(isValidTickVisibilityMode(m) ? m : Slider.TICK_VISIBILITY_AUTO_HIDE);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass only TICK_VISIBILITY_* constants; keep @IntDef lint active.","Persist modes as stable strings, map back to constants on read."],"tags":["android","slider","material-components","invariant","unreachable-default"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}