material-components/material-components-android · error · UnsupportedOperationException
Changing flex wrap not allowed. ChipGroup exposes a singleLi
Error message
Changing flex wrap not allowed. ChipGroup exposes a singleLine attribute instead.
What it means
ChipGroup intentionally wraps chips itself and exposes only a singleLine flag to switch between wrapping and horizontal scrolling. setFlexWrap (inherited vocabulary from FlexboxLayout compatibility) is deprecated and throws UnsupportedOperationException, redirecting you to setSingleLine.
Source
Thrown at lib/java/com/google/android/material/chip/ChipGroup.java:262
/** @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.");
}
/** @deprecated Use {@link ChipGroup#setChipSpacingVertical(int)} instead. */
@Deprecated
public void setShowDividerVertical(int dividerMode) {
throw new UnsupportedOperationException(
"Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.");
}
/** @deprecated Use {@link ChipGroup#setSingleLine(int)} instead. */
@Deprecated
public void setFlexWrap(int flexWrap) {
throw new UnsupportedOperationException(
"Changing flex wrap not allowed. ChipGroup exposes a singleLine attribute instead.");
}
/**
* Sets the selection to the chip whose identifier is passed in parameter.
*
* <p>In {@link #isSingleSelection() single selection mode}, checking a chip also unchecks all
* others.
*
* @param id the unique id of the chip to select in this group
* @see #getCheckedChipId()
* @see #clearCheck()
*/
public void check(@IdRes int id) {
checkableGroup.check(id);
}
/**
* When in {@link #isSingleSelection() single selection mode}, returns the identifier of theView on GitHub (pinned to ac7e18efee)
Solutions
- Remove setFlexWrap; ChipGroup wraps by default.
- For a single non-wapping row, set chipGroup.setSingleLine(true) or app:singleLine="true" (which enables horizontal scrolling).
- For custom wrap behavior beyond these two modes, use FlexboxLayout or Flow with regular views.
Example fix
// before chipGroup.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP) // throws // after // ChipGroup wraps chips by default; do nothing. chipGroup.isSingleLine = false
Defensive patterns
Strategy: validation
Validate before calling
fun configureWrap(group: ChipGroup, singleLine: Boolean) {
group.isSingleLine = singleLine // true = horizontal scroll; false = wrap (default)
// never call setFlexWrap
} Prevention
- Remember ChipGroup wraps by default; singleLine=true opts into scrolling.
- Do not assume FlexboxLayout APIs exist on ChipGroup.
- Use FlexboxLayout directly for advanced flex behavior.
When it happens
Trigger: Calling chipGroup.setFlexWrap(FLEX_WRAP_WRAP) or any flexWrap constant; migrating FlexboxLayout code to ChipGroup; IDE auto-completing the deprecated method.
Common situations: Replacing FlexboxLayout-based tag clouds with ChipGroup and carrying over flex-wrap configuration; assuming ChipGroup subclasses FlexboxLayout (it does not).
Related errors
- Changing divider drawables have no effect. ChipGroup do not
- Changing divider modes has no effect. ChipGroup do not use d
- secondaryIconGravity cannot have the same alignment as iconG
- Attempted to set ShapeAppearanceModel on a MaterialButton wh
- Attempted to get ShapeAppearanceModel from a MaterialButton
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/c7d66d4c770cae89.
Report an issue: GitHub.