material-components/material-components-android · error · IllegalStateException
The current box background mode is not supported by the end
Error message
The current box background mode is not supported by the end icon mode
What it means
EndCompoundLayout.setEndIconMode checks each EndIconDelegate's supported box background modes (isBoxBackgroundModeSupported). For example, the dropdown-menu delegate is only supported with filled/outlined box backgrounds, not BOX_BACKGROUND_NONE. When the TextInputLayout's current box background mode is unsupported for the requested end icon mode, it throws IllegalStateException naming both values.
Source
Thrown at lib/java/com/google/android/material/textfield/EndCompoundLayout.java:382
return endIconMode;
}
void setEndIconMode(@EndIconMode int endIconMode) {
if (this.endIconMode == endIconMode) {
return;
}
tearDownDelegate(getEndIconDelegate());
int previousEndIconMode = this.endIconMode;
this.endIconMode = endIconMode;
dispatchOnEndIconChanged(previousEndIconMode);
setEndIconVisible(endIconMode != END_ICON_NONE);
EndIconDelegate delegate = getEndIconDelegate();
setEndIconDrawable(getIconResId(delegate));
setEndIconCheckable(delegate.isIconCheckable());
if (delegate.isBoxBackgroundModeSupported(textInputLayout.getBoxBackgroundMode())) {
setUpDelegate(delegate);
} else {
throw new IllegalStateException(
"The current box background mode "
+ textInputLayout.getBoxBackgroundMode()
+ " is not supported by the end icon mode "
+ endIconMode);
}
setEndIconOnClickListener(delegate.getOnIconClickListener());
setEndIconContentDescription(delegate.getIconContentDescriptionResId());
if (editText != null) {
delegate.onEditTextAttached(editText);
setOnFocusChangeListenersIfNeeded(delegate);
}
applyIconTint(textInputLayout, endIconView, endIconTintList, endIconTintMode);
refreshIconState(/* force= */ true);
}
void refreshIconState(boolean force) {
boolean stateChanged = false;
EndIconDelegate delegate = getEndIconDelegate();View on GitHub (pinned to ac7e18efee)
Solutions
- Use the matched style, e.g. Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu / Widget.Material3.TextInputLayout.*.ExposedDropdownMenu.
- Or set the box background mode to filled/outlined before enabling the dropdown end icon: setBoxBackgroundMode(BOX_BACKGROUND_OUTLINE).
- Keep the end icon mode consistent with the layout style (no dropdown icon on underline-only layouts).
Example fix
<!-- before -->
<com.google.android.material.textfield.TextInputLayout
app:endIconMode="dropdown_menu"> <!-- default box mode = none -> throws -->
<!-- after -->
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"> Defensive patterns
Strategy: validation
Validate before calling
// Dropdown end icon requires a box background (filled/outlined):
int box = til.getBoxBackgroundMode();
boolean boxOk = box == TextInputLayout.BOX_BACKGROUND_FILLED
|| box == TextInputLayout.BOX_BACKGROUND_OUTLINE;
if (boxOk) til.setEndIconMode(TextInputLayout.END_ICON_DROPDOWN_MENU); Prevention
- Use the ExposedDropdownMenu TextInputLayout styles instead of mixing attributes by hand.
- If setting modes in code, set the box background mode before the dropdown end icon mode.
- Never combine dropdown end icon with underline (BOX_BACKGROUND_NONE) layouts.
When it happens
Trigger: setEndIconMode(END_ICON_DROPDOWN_MENU) (or app:endIconMode="dropdown_menu") while the TextInputLayout uses boxBackgroundMode none (plain underline style); password-toggle/custom icons on unsupported box modes.
Common situations: Enabling dropdown menu on a default (non-box) TextInputLayout style instead of an ExposedDropdownMenu style; changing app:boxBackgroundMode at runtime after setting the end icon mode.
Related errors
- EditText needs to be an AutoCompleteTextView if an Exposed D
- > boxBackgroundMode < is illegal; only @BoxBackgroundMode co
- endIconSize cannot be less than 0
- Invalid end icon mode:
- startIconSize cannot be less than 0
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/6f66f05dcd84f285.
Report an issue: GitHub.