Tencent/QMUI_Android · error · RuntimeException
mCompiler == null
Error message
mCompiler == null
What it means
QMUIQQFaceView.setText() throws a RuntimeException when QQ face parsing is enabled (mOpenQQFace == true) but no compiler has been installed via setCompiler(). Without the compiler the view cannot parse face codes, so it fails fast at setText time rather than rendering raw codes.
Source
Thrown at qmui/src/main/java/com/qmuiteam/qmui/qqface/QMUIQQFaceView.java:532
* @return
*/
public Rect getMoreHitRect() {
return mMoreHitRect;
}
public void setText(CharSequence charSequence) {
setText(charSequence, true);
}
private void setText(CharSequence charSequence, boolean compareOldText) {
if (compareOldText && QMUILangHelper.objectEquals(charSequence, mOriginText)) {
return;
}
mOriginText = charSequence;
setContentDescription(charSequence);
if (mOpenQQFace && mCompiler == null) {
throw new RuntimeException("mCompiler == null");
}
mSpanInfos.clear();
if (QMUILangHelper.isNullOrEmpty(mOriginText)) {
mElementList = null;
requestLayout();
invalidate();
return;
}
if (mOpenQQFace && mCompiler != null) {
mElementList = mCompiler.compile(mOriginText);
List<QMUIQQFaceCompiler.Element> elements = mElementList.getElements();
if (elements != null) {
for (int i = 0; i < elements.size(); i++) {
QMUIQQFaceCompiler.Element element = elements.get(i);
if (element.getType() == QMUIQQFaceCompiler.ElementType.SPAN) {
mSpanInfos.put(element, new SpanInfo(element.getTouchableSpan()));View on GitHub (pinned to 026e7d4866)
Solutions
- Call setCompiler(new QMUIQQFaceCompiler(context)) before the first setText (typically right after inflating/constructing the view).
- If faces are not needed, disable them (qmui_open_qq_face=false / setter) instead of leaving the compiler unset.
- Move setCompiler earlier in initialization so it precedes any programmatic or constructor-driven setText.
Example fix
// before
QMUIQQFaceView view = findViewById(R.id.qq_face_view); // openQQFace=true
view.setText("hello [QQ emoji] "); // throws
// after
QMUIQQFaceView view = findViewById(R.id.qq_face_view);
view.setCompiler(new QMUIQQFaceCompiler(context));
view.setText("hello [QQ emoji] "); Defensive patterns
Strategy: validation
Validate before calling
if (view.isOpenQQFace() && view.getCompiler() == null) {
view.setCompiler(new QMUIQQFaceCompiler(context));
}
view.setText(text); Type guard
boolean isQQFaceViewReady(QMUIQQFaceView v) {
return !v.isOpenQQFace() || v.getCompiler() != null;
} Try / catch
try {
view.setText(text);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("mCompiler == null")) {
view.setCompiler(new QMUIQQFaceCompiler(context));
view.setText(text);
} else throw e;
} Prevention
- Call setCompiler immediately after creating/inflating QMUIQQFaceView
- Disable qmui_open_qq_face if face parsing is unused
- Centralize QMUIQQFaceView construction in a factory that always installs the compiler
When it happens
Trigger: Enabling openQQFace (XML attribute or setter) on a QMUIQQFaceView and then calling setText() without ever calling setCompiler(new QMUIQQFaceCompiler(...)).
Common situations: Adding a QMUIQQFaceView in XML with app:qmui_open_qq_face="true" but forgetting the compiler setup; view created before the compiler-dependent module init; constructors calling setText before setCompiler.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- start must >= 0 and < text.length
- end must > start
- Not support the type: %s
- topView must implement from IQMUIContinuousNestedTopView
- bottomView must implement from IQMUIContinuousNestedBottomVi
AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06).
Data as JSON: /api/errors/b0ac064379b411b5.
Report an issue: GitHub.