{"record":{"id":"766a3ef916830593","repo":"Tencent/QMUI_Android","slug":"can-not-instance-the-class-recordmetamapimpl-plea","errorCode":null,"errorMessage":"Can not instance the Class RecordMetaMapImpl. Please file a issue to report this.","messagePattern":"Can not instance the Class RecordMetaMapImpl\\. Please file a issue to report this\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"arch/src/main/java/com/qmuiteam/qmui/arch/QMUILatestVisit.java","lineNumber":55,"sourceCode":"            Class<?> cls = Class.forName(RecordIdClassMap.class.getCanonicalName() + \"Impl\");\n            mRecordMap = (RecordIdClassMap) cls.newInstance();\n        } catch (ClassNotFoundException e) {\n            mRecordMap = new RecordIdClassMap() {\n                @Override\n                public Class<?> getRecordClassById(int id) {\n                    return null;\n                }\n\n                @Override\n                public int getIdByRecordClass(Class<?> clazz) {\n                    return QMUILatestVisitStorage.NOT_EXIST;\n                }\n            };\n        } catch (IllegalAccessException e) {\n            throw new RuntimeException(\"Can not access the Class RecordMetaMapImpl. \" +\n                    \"Please file a issue to report this.\");\n        } catch (InstantiationException e) {\n            throw new RuntimeException(\"Can not instance the Class RecordMetaMapImpl. \" +\n                    \"Please file a issue to report this.\");\n        }\n    }\n\n    @MainThread\n    public static QMUILatestVisit getInstance(Context context) {\n        if (sInstance == null) {\n            sInstance = new QMUILatestVisit(context);\n        }\n        return sInstance;\n    }\n\n    public static Intent intentOfLatestVisit(Activity activity) {\n        return getInstance(activity).getLatestVisitIntent(activity);\n    }\n\n    public void setStorage(QMUILatestVisitStorage storage) {\n        mStorage = storage;","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/arch/src/main/java/com/qmuiteam/qmui/arch/QMUILatestVisit.java#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"Minified release builds, hot-patch/InstantRun tooling replacing class bytes, custom gradle transforms, or a genuinely corrupted dependency artifact.","solutions":["Add/verify keep rules so RecordMetaMapImpl and its default constructor survive: -keep class com.qmuiteam.qmui.arch.QMUILatestVisit$RecordMetaMapImpl { *; }.","Clean and re-sync dependencies to rule out a corrupted artifact (./gradlew clean --refresh-dependencies).","Disable suspect bytecode transforms (hot-fix plugins, gradle transforms) to isolate the cause.","Upgrade the QMUI dependency or report the issue upstream with build and device details."],"exampleFix":"// before\n# nothing\n// after\n-keep class com.qmuiteam.qmui.arch.QMUILatestVisit { *; }\n-keep class com.qmuiteam.qmui.arch.QMUILatestVisit$RecordMetaMapImpl { <init>(); *; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    QMUILatestVisit.getInstance(context);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Can not instance\")) {\n        Log.e(TAG, \"RecordMetaMapImpl instantiation failed; check build transforms\", e);\n    } else throw e;\n}","preventionTips":["Add -keepattributes Signature and keep rules for QMUILatestVisit internals","Avoid bytecode transforms/hot-patch tools on library classes","Rebuild with clean dependencies if the error appears suddenly"],"tags":["android","reflection","instantiation","proguard"],"backgroundTag":"class-not-found","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}