{"record":{"id":"20e0c81269ee1452","repo":"material-components/material-components-android","slug":"transient-bottom-bar-must-have-non-null-content","errorCode":null,"errorMessage":"Transient bottom bar must have non-null content","messagePattern":"Transient bottom bar must have non-null content","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"lib/java/com/google/android/material/snackbar/BaseTransientBottomBar.java","lineNumber":358,"sourceCode":"   * @param contentViewCallback The content view callback for this transient bottom bar.\n   */\n  protected BaseTransientBottomBar(\n      @NonNull ViewGroup parent,\n      @NonNull View content,\n      @NonNull com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {\n    this(parent.getContext(), parent, content, contentViewCallback);\n  }\n\n  protected BaseTransientBottomBar(\n      @NonNull Context context,\n      @NonNull ViewGroup parent,\n      @NonNull View content,\n      @NonNull com.google.android.material.snackbar.ContentViewCallback contentViewCallback) {\n    if (parent == null) {\n      throw new IllegalArgumentException(\"Transient bottom bar must have non-null parent\");\n    }\n    if (content == null) {\n      throw new IllegalArgumentException(\"Transient bottom bar must have non-null content\");\n    }\n    if (contentViewCallback == null) {\n      throw new IllegalArgumentException(\"Transient bottom bar must have non-null callback\");\n    }\n\n    targetParent = parent;\n    this.contentViewCallback = contentViewCallback;\n    this.context = context;\n\n    ThemeEnforcement.checkAppCompatTheme(context);\n\n    LayoutInflater inflater = LayoutInflater.from(context);\n    // Note that for backwards compatibility reasons we inflate a layout that is defined\n    // in the extending Snackbar class. This is to prevent breakage of apps that have custom\n    // coordinator layout behaviors that depend on that layout.\n    view = (SnackbarBaseLayout) inflater.inflate(getSnackbarBaseLayoutResId(), targetParent, false);\n    view.setBaseTransientBottomBar(this);\n    if (content instanceof SnackbarContentLayout) {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/material-components/material-components-android/blob/ac7e18efeefb331850c561faf9ab8bf81d27ba68/lib/java/com/google/android/material/snackbar/BaseTransientBottomBar.java#L340-L376","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom snackbars/transients with a content view loaded from a binding or findViewById that returned null (wrong ID or wrong layout in some configuration).","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."],"exampleFix":"// before\nnew CustomTransient(parent, null /* content */, callback); // throws\n\n// after\nView content = inflater.inflate(R.layout.custom_transient_content, parent, false);\nnew CustomTransient(parent, content, callback);","handlingStrategy":"validation","validationCode":"View content = LayoutInflater.from(context).inflate(R.layout.my_content, parent, false);\nif (content != null) {\n  new MyTransientBar((ViewGroup) parent, content, callback).show();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check inflated content in custom transients before calling super.","Verify layout IDs exist in every flavor/variant."],"tags":["android","snackbar","material-components","null-safety","immediate"],"backgroundTag":null,"analyzedSha":"ac7e18efeefb331850c561faf9ab8bf81d27ba68","analyzedAt":"2026-08-14T15:35:35.735Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}