material-components/material-components-android · error · IllegalArgumentException
Transient bottom bar must have non-null content
Error message
Transient bottom bar must have non-null content
What it means
IllegalArgumentException from the BaseTransientBottomBar constructor when the content View is null. The content view is what gets inflated into the transient bar; a null means the caller (usually a subclass or custom transient) passed an unresolved or not-yet-created view.
Source
Thrown at lib/java/com/google/android/material/snackbar/BaseTransientBottomBar.java:358
* @param contentViewCallback The content view callback for this transient bottom bar.
*/
protected BaseTransientBottomBar(
@NonNull ViewGroup parent,
@NonNull View content,
@NonNull com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {
this(parent.getContext(), parent, content, contentViewCallback);
}
protected BaseTransientBottomBar(
@NonNull Context context,
@NonNull ViewGroup parent,
@NonNull View content,
@NonNull com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {
if (parent == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null parent");
}
if (content == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null content");
}
if (contentViewCallback == null) {
throw new IllegalArgumentException("Transient bottom bar must have non-null callback");
}
targetParent = parent;
this.contentViewCallback = contentViewCallback;
this.context = context;
ThemeEnforcement.checkAppCompatTheme(context);
LayoutInflater inflater = LayoutInflater.from(context);
// Note that for backwards compatibility reasons we inflate a layout that is defined
// in the extending Snackbar class. This is to prevent breakage of apps that have custom
// coordinator layout behaviors that depend on that layout.
view = (SnackbarBaseLayout) inflater.inflate(getSnackbarBaseLayoutResId(), targetParent, false);
view.setBaseTransientBottomBar(this);
if (content instanceof SnackbarContentLayout) {View on GitHub (pinned to ac7e18efee)
Solutions
- Verify the content view inflation succeeded before constructing the bar.
- Check the layout ID passed to inflate matches an existing layout resource in all build variants/flavors.
- Fail fast in debug builds with an assertion on non-null content.
Example fix
// before new CustomTransient(parent, null /* content */, callback); // throws // after View content = inflater.inflate(R.layout.custom_transient_content, parent, false); new CustomTransient(parent, content, callback);
Defensive patterns
Strategy: validation
Validate before calling
View content = LayoutInflater.from(context).inflate(R.layout.my_content, parent, false);
if (content != null) {
new MyTransientBar((ViewGroup) parent, content, callback).show();
} Prevention
- Null-check inflated content in custom transients before calling super.
- Verify layout IDs exist in every flavor/variant.
When it happens
Trigger: Custom BaseTransientBottomBar subclasses passing a null content view; inflater.inflate(...) returning effectively unusable results being mis-handled; interop code where the content argument is optional and null slips through.
Common situations: Custom snackbars/transients with a content view loaded from a binding or findViewById that returned null (wrong ID or wrong layout in some configuration).
Related errors
- Transient bottom bar must have non-null parent
- Transient bottom bar must have non-null callback
- Unable to find anchor view with id:
- At least one value must be set
- The continuousModeTickCount(%s) must be greater than or equa
AI-assisted analysis of material-components/material-components-android@ac7e18efee (2026-08-14).
Data as JSON: /api/errors/20e0c81269ee1452.
Report an issue: GitHub.