{"record":{"id":"c7d66d4c770cae89","repo":"material-components/material-components-android","slug":"changing-flex-wrap-not-allowed-chipgroup-exposes","errorCode":null,"errorMessage":"Changing flex wrap not allowed. ChipGroup exposes a singleLine attribute instead.","messagePattern":"Changing flex wrap not allowed\\. ChipGroup exposes a singleLine attribute instead\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/chip/ChipGroup.java","lineNumber":262,"sourceCode":"\n  /** @deprecated Use {@link ChipGroup#setChipSpacingHorizontal(int)} instead. */\n  @Deprecated\n  public void setShowDividerHorizontal(int dividerMode) {\n    throw new UnsupportedOperationException(\n        \"Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.\");\n  }\n\n  /** @deprecated Use {@link ChipGroup#setChipSpacingVertical(int)} instead. */\n  @Deprecated\n  public void setShowDividerVertical(int dividerMode) {\n    throw new UnsupportedOperationException(\n        \"Changing divider modes has no effect. ChipGroup do not use divider drawables as spacing.\");\n  }\n\n  /** @deprecated Use {@link ChipGroup#setSingleLine(int)} instead. */\n  @Deprecated\n  public void setFlexWrap(int flexWrap) {\n    throw new UnsupportedOperationException(\n        \"Changing flex wrap not allowed. ChipGroup exposes a singleLine attribute instead.\");\n  }\n\n  /**\n   * Sets the selection to the chip whose identifier is passed in parameter.\n   *\n   * <p>In {@link #isSingleSelection() single selection mode}, checking a chip also unchecks all\n   * others.\n   *\n   * @param id the unique id of the chip to select in this group\n   * @see #getCheckedChipId()\n   * @see #clearCheck()\n   */\n  public void check(@IdRes int id) {\n    checkableGroup.check(id);\n  }\n  /**\n   * When in {@link #isSingleSelection() single selection mode}, returns the identifier of the","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/chip/ChipGroup.java#L244-L280","documentation":"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.","triggerScenarios":"Calling chipGroup.setFlexWrap(FLEX_WRAP_WRAP) or any flexWrap constant; migrating FlexboxLayout code to ChipGroup; IDE auto-completing the deprecated method.","commonSituations":"Replacing FlexboxLayout-based tag clouds with ChipGroup and carrying over flex-wrap configuration; assuming ChipGroup subclasses FlexboxLayout (it does not).","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."],"exampleFix":"// before\nchipGroup.setFlexWrap(FlexboxLayout.FLEX_WRAP_WRAP) // throws\n\n// after\n// ChipGroup wraps chips by default; do nothing.\nchipGroup.isSingleLine = false","handlingStrategy":"validation","validationCode":"fun configureWrap(group: ChipGroup, singleLine: Boolean) {\n  group.isSingleLine = singleLine // true = horizontal scroll; false = wrap (default)\n  // never call setFlexWrap\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["android","material-components","chipgroup","deprecated","flexbox"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}