{"record":{"id":"b4b3df1698a31d10","repo":"Tencent/QMUI_Android","slug":"customfactory-must-implement-interface-qmuischemef","errorCode":null,"errorMessage":"customFactory must implement interface QMUISchemeFragmentFactory.","messagePattern":"customFactory must implement interface QMUISchemeFragmentFactory\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java","lineNumber":347,"sourceCode":"            builder.add(\"}\");\n        }\n        return builder.build();\n    }\n\n\n    private CodeBlock generateCustomFactory(boolean isActivity, AnnotationMirror annotationMirror){\n        AnnotationValue customFactory = getAnnotationValue(annotationMirror, \"customFactory\");\n        if (customFactory == null) {\n            return CodeBlock.of(\"null\");\n        }\n        TypeMirror typeMirror = (TypeMirror) customFactory.getValue();\n        if(isActivity){\n            if (!isSubtypeOfType(typeMirror, QMUISchemeIntentFactoryType)) {\n                throw new IllegalStateException(\"customFactory must implement interface QMUISchemeIntentFactory.\");\n            }\n        }else{\n            if (!isSubtypeOfType(typeMirror, QMUISchemeFragmentFactoryType)) {\n                throw new IllegalStateException(\"customFactory must implement interface QMUISchemeFragmentFactory.\");\n            }\n        }\n\n        return CodeBlock.of(\"$T.class\", typeMirror);\n    }\n\n    private CodeBlock generateCustomMatcher(AnnotationMirror annotationMirror){\n        AnnotationValue customFactory = getAnnotationValue(annotationMirror, \"customMatcher\");\n        if (customFactory == null) {\n            return CodeBlock.of(\"null\");\n        }\n        TypeMirror typeMirror = (TypeMirror) customFactory.getValue();\n        if (!isSubtypeOfType(typeMirror, QMUISchemeMatcherType)) {\n            throw new IllegalStateException(\"customMatcher must implement interface QMUISchemeMatcher.\");\n        }\n\n        return CodeBlock.of(\"$T.class\", typeMirror);\n    }","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java#L329-L365","documentation":"The fragment-side counterpart of error 24: generateCustomFactory requires that for fragment schemes (isActivity == false) the customFactory class implements QMUISchemeFragmentFactory. The processor throws IllegalStateException when the subtype check fails.","triggerScenarios":"Annotating a Fragment with a scheme annotation whose customFactory element references a class that does not implement QMUISchemeFragmentFactory.","commonSituations":"Reusing an activity's QMUISchemeIntentFactory implementation for a fragment scheme; factory class lost its interface after refactoring; wrong import of the factory interface.","solutions":["Implement QMUISchemeFragmentFactory in the customFactory class used by the fragment scheme.","If it is actually an activity factory, move it to the activity's scheme annotation and create a fragment-specific factory.","Confirm the correct QMUISchemeFragmentFactory import is used in the factory class declaration."],"exampleFix":"// before\nclass MyFragmentFactory : QMUISchemeIntentFactory { ... } // wrong interface\n\n// after\nclass MyFragmentFactory : QMUISchemeFragmentFactory { override fun create(fragment: QMUIFragment, ...): QMUIFragment? = ... }","handlingStrategy":"validation","validationCode":"fun validateFragmentFactory(cls: Class<*>) =\n    check(QMUISchemeFragmentFactory::class.java.isAssignableFrom(cls)) { \"${cls.name} must implement QMUISchemeFragmentFactory\" }","typeGuard":"fun isValidFragmentFactory(cls: Class<*>): Boolean =\n    QMUISchemeFragmentFactory::class.java.isAssignableFrom(cls)","tryCatchPattern":null,"preventionTips":["Always implement QMUISchemeFragmentFactory for fragment customFactory classes","Don't reuse an activity's intent factory on a fragment scheme","Verify interface imports when refactoring factory classes"],"tags":["annotation-processor","compile-time","scheme","type-check"],"backgroundTag":"type-mismatch","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}