Tencent/QMUI_Android · error · RuntimeException
you should call addView() to add content view
Error message
you should call addView() to add content view
What it means
QMUIFullScreenPopup.show() throws a RuntimeException when the popup's internal view list is empty, meaning addView() was never called before showing. The popup has nothing to display onto the decor view, so it refuses to proceed.
Source
Thrown at qmui/src/main/java/com/qmuiteam/qmui/widget/popup/QMUIFullScreenPopup.java:160
QMUISkinValueBuilder builder = QMUISkinValueBuilder.acquire().src(mCloseIconAttr);
QMUISkinHelper.setSkinValue(closeBtn, builder);
builder.release();
drawable = QMUIResHelper.getAttrDrawable(mContext, mCloseIconAttr);
}
closeBtn.setImageDrawable(drawable);
return closeBtn;
}
public boolean isShowing() {
return mWindow.isShowing();
}
public void show(View parent) {
if (isShowing()) {
return;
}
if (mViews.isEmpty()) {
throw new RuntimeException("you should call addView() to add content view");
}
ArrayList<ViewInfo> views = new ArrayList<>(mViews);
RootView rootView = new RootView(mContext);
for (int i = 0; i < views.size(); i++) {
ViewInfo info = mViews.get(i);
View view = info.view;
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
rootView.addView(view, info.lp);
}
if (mAddCloseBtn) {
if (mCloseIvLayoutParams == null) {
mCloseIvLayoutParams = defaultCloseIvLp();
}
rootView.addView(createCloseIv(), mCloseIvLayoutParams);
}View on GitHub (pinned to 026e7d4866)
Solutions
- Call popup.addView(contentView) (optionally with LayoutParams) at least once before popup.show(parent).
- Add a guard: only call show() if at least one view was added.
- Ensure the code path that shows the popup is the same one that populated it.
Example fix
// before QMUIFullScreenPopup popup = QMUIFullScreenPopup.create(context); popup.show(parent); // crashes: no views added // after QMUIFullScreenPopup popup = QMUIFullScreenPopup.create(context); popup.addView(contentView); popup.show(parent);
Defensive patterns
Strategy: validation
Validate before calling
if (popupHasNoViews) { popup.addView(contentView); }
popup.show(parent); Try / catch
try {
popup.show(parent);
} catch (RuntimeException e) {
Log.e(TAG, "popup had no views; configure addView() before show()", e);
} Prevention
- Always pair popup creation with at least one addView() call in the same factory/builder function.
- Only call show() after content configuration completes (including async paths).
- Track a boolean 'configured' flag to gate show().
When it happens
Trigger: Calling popup.show(parent) without any prior popup.addView(view) (or addView(view, layoutParams)) call; also if show() is called after the popup was cleared/rebuilt and no views were re-added.
Common situations: Building the popup conditionally so all addView() calls are skipped; forgetting to add views after copying popup construction code; calling show() from a different code path than the one that configured views.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- you should call view() to set your content view
- Not support the type: %s
- topView must implement from IQMUIContinuousNestedTopView
- bottomView must implement from IQMUIContinuousNestedBottomVi
- delegateView must be a instance of View
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/18d368fd2d9f7a15.
Report an issue: GitHub.