material-components/material-components-android · error · IllegalStateException
The inactive and active ticks are different colors. Use the
Error message
The inactive and active ticks are different colors. Use the getTickColorInactive() and getTickColorActive() methods instead.
What it means
IllegalStateException thrown by getTickTintList() when the inactive and active tick colors have been set to different ColorStateLists. The unified getter can only return a meaningful value when both halves share one color; otherwise callers must use getTickInactiveTintList() and getTickActiveTintList().
Source
Thrown at lib/java/com/google/android/material/slider/BaseSlider.java:1846
invalidate();
}
/**
* Returns the color of the tick if the active and inactive parts aren't different.
*
* @throws IllegalStateException If {@code tickColorActive} and {@code tickColorInactive} have
* been set to different values.
* @see #setTickTintList(ColorStateList)
* @see #setTickInactiveTintList(ColorStateList)
* @see #setTickActiveTintList(ColorStateList)
* @see #getTickInactiveTintList()
* @see #getTickActiveTintList()
* @attr ref com.google.android.material.R.styleable#Slider_tickColor
*/
@NonNull
public ColorStateList getTickTintList() {
if (!tickColorInactive.equals(tickColorActive)) {
throw new IllegalStateException(
"The inactive and active ticks are different colors. Use the getTickColorInactive() and"
+ " getTickColorActive() methods instead.");
}
return tickColorActive;
}
/**
* Sets the color of the tick marks.
*
* @see #setTickInactiveTintList(ColorStateList)
* @see #setTickActiveTintList(ColorStateList)
* @see #getTickTintList()
* @attr ref com.google.android.material.R.styleable#Slider_tickColor
*/
public void setTickTintList(@NonNull ColorStateList tickColor) {
setTickInactiveTintList(tickColor);
setTickActiveTintList(tickColor);
}View on GitHub (pinned to ac7e18efee)
Solutions
- Use getTickInactiveTintList() and getTickActiveTintList() instead of the combined getter.
- Only call getTickTintList() when you know both colors were set from the same source.
- If a single color is intended, re-apply it with setTickTintList(color) so both halves match.
Example fix
// before ColorStateList ticks = slider.getTickTintList(); // throws when they differ // after ColorStateList inactive = slider.getTickInactiveTintList(); ColorStateList active = slider.getTickActiveTintList();
Defensive patterns
Strategy: validation
Validate before calling
ColorStateList inactive = slider.getTickInactiveTintList(); ColorStateList active = slider.getTickActiveTintList(); // never call getTickTintList() unless you set both via setTickTintList()
Try / catch
If you must call the combined getter in shared code: try { ... } catch (IllegalStateException e) { /* fall back to the split getters */ } Prevention
- Prefer the split getters (Inactive/Active) in generic code.
- Only use the combined getter immediately after setTickTintList().
When it happens
Trigger: Calling setTickInactiveTintList(a) and setTickActiveTintList(b) with a != b (or setting only app:tickColorInactive/app:tickColorActive differently in XML), then calling getTickTintList().
Common situations: Theme code that assumes a single tick color while the design system styles active/inactive ticks differently; generic 'read tint, mutate, re-apply' utilities applied to a Material slider.
Related errors
- The inactive and active parts of the track are different col
- indicatorColors cannot be empty when indicatorColor is not u
- The stepSize(%s) must be 0, or a factor of the valueFrom(%s)
- valueFrom(%s) must be smaller than valueTo(%s)
- Slider value(%s) must be greater or equal to valueFrom(%s),
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/1f6c7d908b70067c.
Report an issue: GitHub.