Tencent/QMUI_Android · error · RuntimeException

Can not instance the Class RecordMetaMapImpl. Please file a

Error message

Can not instance the Class RecordMetaMapImpl. Please file a issue to report this.

What it means

Same reflective static-init path as the access error: QMUILatestVisit tries Class.newInstance() on the internal RecordMetaMapImpl, and an InstantiationException means the class could not be instantiated (missing no-arg constructor, abstract/interface, or constructor threw). The library converts it into a RuntimeException telling the developer to report it, since this is an internal invariant, not something app code normally controls.

Source

Thrown at arch/src/main/java/com/qmuiteam/qmui/arch/QMUILatestVisit.java:55

            Class<?> cls = Class.forName(RecordIdClassMap.class.getCanonicalName() + "Impl");
            mRecordMap = (RecordIdClassMap) cls.newInstance();
        } catch (ClassNotFoundException e) {
            mRecordMap = new RecordIdClassMap() {
                @Override
                public Class<?> getRecordClassById(int id) {
                    return null;
                }

                @Override
                public int getIdByRecordClass(Class<?> clazz) {
                    return QMUILatestVisitStorage.NOT_EXIST;
                }
            };
        } catch (IllegalAccessException e) {
            throw new RuntimeException("Can not access the Class RecordMetaMapImpl. " +
                    "Please file a issue to report this.");
        } catch (InstantiationException e) {
            throw new RuntimeException("Can not instance the Class RecordMetaMapImpl. " +
                    "Please file a issue to report this.");
        }
    }

    @MainThread
    public static QMUILatestVisit getInstance(Context context) {
        if (sInstance == null) {
            sInstance = new QMUILatestVisit(context);
        }
        return sInstance;
    }

    public static Intent intentOfLatestVisit(Activity activity) {
        return getInstance(activity).getLatestVisitIntent(activity);
    }

    public void setStorage(QMUILatestVisitStorage storage) {
        mStorage = storage;

View on GitHub (pinned to 026e7d4866)

Solutions

  1. Add/verify keep rules so RecordMetaMapImpl and its default constructor survive: -keep class com.qmuiteam.qmui.arch.QMUILatestVisit$RecordMetaMapImpl { *; }.
  2. Clean and re-sync dependencies to rule out a corrupted artifact (./gradlew clean --refresh-dependencies).
  3. Disable suspect bytecode transforms (hot-fix plugins, gradle transforms) to isolate the cause.
  4. Upgrade the QMUI dependency or report the issue upstream with build and device details.

Example fix

// before
# nothing
// after
-keep class com.qmuiteam.qmui.arch.QMUILatestVisit { *; }
-keep class com.qmuiteam.qmui.arch.QMUILatestVisit$RecordMetaMapImpl { <init>(); *; }
Defensive patterns

Strategy: try-catch

Try / catch

try {
    QMUILatestVisit.getInstance(context);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("Can not instance")) {
        Log.e(TAG, "RecordMetaMapImpl instantiation failed; check build transforms", e);
    } else throw e;
}

Prevention

When it happens

Trigger: Triggering QMUILatestVisit class initialization when RecordMetaMapImpl lacks an accessible no-arg constructor after transformation — commonly due to R8/ProGuard optimization altering constructors, or bytecode manipulation (instrumentation, hot-fix frameworks) breaking the class.

Common situations: Minified release builds, hot-patch/InstantRun tooling replacing class bytes, custom gradle transforms, or a genuinely corrupted dependency artifact.

Related errors


AI-assisted analysis of Tencent/QMUI_Android@026e7d4866 (2026-09-06). Data as JSON: /api/errors/766a3ef916830593. Report an issue: GitHub.