{"record":{"id":"2c8b415861faf61b","repo":"Tencent/QMUI_Android","slug":"customfactory-must-implement-interface-qmuischemei","errorCode":null,"errorMessage":"customFactory must implement interface QMUISchemeIntentFactory.","messagePattern":"customFactory must implement interface QMUISchemeIntentFactory\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java","lineNumber":343,"sourceCode":"                    builder.add(\",\");\n                }\n                builder.add(\"$S\", keys[i]);\n            }\n            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.\");","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java#L325-L361","documentation":"SchemeProcessor.generateCustomFactory validates the customFactory annotation value at compile time. For @SchemeActivity (isActivity == true) the provided class must implement QMUISchemeIntentFactory; otherwise the processor throws this IllegalStateException, failing the build.","triggerScenarios":"Annotating an Activity with a scheme annotation whose customFactory element points to a class that does not implement QMUISchemeIntentFactory.","commonSituations":"Copy-pasting a fragment factory into an activity scheme; refactoring the factory to drop the interface; typos in the import causing the wrong QMUISchemeIntentFactory to be referenced.","solutions":["Make the customFactory class implement QMUISchemeIntentFactory for activity schemes.","Verify you imported the correct QMUISchemeIntentFactory interface (arch scheme package).","If the class was meant for a fragment, switch the annotation/site to use QMUISchemeFragmentFactory instead."],"exampleFix":"// before\nclass MyFactory { override fun ... } // no interface\n\n// after\nclass MyFactory : QMUISchemeIntentFactory { override fun create(context: Context, ...): Intent? = ... }","handlingStrategy":"validation","validationCode":"// at the declaration site, ensure:\n// class MyFactory : QMUISchemeIntentFactory  <-- required for activity schemes\nfun validateActivityFactory(cls: Class<*>) =\n    check(QMUISchemeIntentFactory::class.java.isAssignableFrom(cls)) { \"${cls.name} must implement QMUISchemeIntentFactory\" }","typeGuard":"fun isValidActivityFactory(cls: Class<*>): Boolean =\n    QMUISchemeIntentFactory::class.java.isAssignableFrom(cls)","tryCatchPattern":null,"preventionTips":["Always implement QMUISchemeIntentFactory for activity customFactory classes","Use distinct factory classes per scheme kind to avoid copy-paste mistakes","Keep the build compiling in CI so processor IllegalStateExceptions appear immediately"],"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-14T05:17:10.506Z"}