material-components/material-components-android · error · UnsupportedOperationException
Changing divider drawables have no effect. ChipGroup do not
Error message
Changing divider drawables have no effect. ChipGroup do not use divider drawables as spacing.
What it means
ChipGroup is a FlowLayout, not a LinearLayout; spacing between chips is controlled by chipSpacingHorizontal/chipSpacingVertical, not divider drawables. The deprecated setDividerDrawableHorizontal throws UnsupportedOperationException to fail fast instead of silently ignoring the call. The javadoc directs you to setChipSpacingHorizontal.
Source
Thrown at lib/java/com/google/android/material/chip/ChipGroup.java:232
public void setOnHierarchyChangeListener(OnHierarchyChangeListener listener) {
// the user listener is delegated to our pass-through listener
passThroughListener.onHierarchyChangeListener = listener;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
// checks the appropriate chip as requested in the XML file
if (defaultCheckedId != View.NO_ID) {
checkableGroup.check(defaultCheckedId);
}
}
/** @deprecated Use {@link ChipGroup#setChipSpacingHorizontal(int)} instead. */
@Deprecated
public void setDividerDrawableHorizontal(Drawable divider) {
throw new UnsupportedOperationException(
"Changing divider drawables have no effect. ChipGroup do not use divider drawables as "
+ "spacing.");
}
/** @deprecated Use {@link ChipGroup#setChipSpacingVertical(int)} instead. */
@Deprecated
public void setDividerDrawableVertical(@Nullable Drawable divider) {
throw new UnsupportedOperationException(
"Changing divider drawables have no effect. ChipGroup do not use divider drawables as "
+ "spacing.");
}
/** @deprecated Use {@link ChipGroup#setChipSpacingHorizontal(int)} instead. */
@Deprecated
public void setShowDividerHorizontal(int dividerMode) {
throw new UnsupportedOperationException(
"Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.");
}View on GitHub (pinned to ac7e18efee)
Solutions
- Replace setDividerDrawableHorizontal(d) with chipGroup.setChipSpacingHorizontal(dp) or the app:chipSpacingHorizontal XML attribute.
- If actual visual dividers are required, place them as separate child views instead.
Example fix
// before chipGroup.setDividerDrawableHorizontal(divider) // throws // after chipGroup.setChipSpacingHorizontal(resources.getDimensionPixelOffset(R.dimen.chip_spacing))
Defensive patterns
Strategy: validation
Validate before calling
fun setSpacing(group: ChipGroup, @Px horizontal: Int) {
group.chipSpacingHorizontal = horizontal // never call setDividerDrawableHorizontal
} Prevention
- ChipGroup spacing comes only from chipSpacingHorizontal/chipSpacingVertical.
- Delete all divider-drawable code paths when migrating LinearLayout to ChipGroup.
- Treat @Deprecated + throws methods in this library as removed APIs, not soft warnings.
When it happens
Trigger: Calling chipGroup.setDividerDrawableHorizontal(drawable) on a ChipGroup; copying LinearLayout divider setup code onto a ChipGroup.
Common situations: Migrating a LinearLayout of buttons to ChipGroup and carrying over setDividerDrawable calls; Android Studio deprecation autofill picking the method without noticing it throws.
Related errors
- Changing divider modes has no effect. ChipGroup do not use d
- Changing flex wrap not allowed. ChipGroup exposes a singleLi
- The wrap overflow mode is not compatible to the vertical ori
- The wrap overflow mode is not compatible with wrap_content l
- All children of a RecyclerView using CarouselLayoutManager m
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/8e90786cb62da481.
Report an issue: GitHub.