{"record":{"id":"4ee70644d06a62f8","repo":"alibaba/ARouter","slug":"the-route-is-marked-on-unsupported-class-look-at","errorCode":null,"errorMessage":"The @Route is marked on unsupported class, look at [<type>].","messagePattern":"The @Route is marked on unsupported class, look at \\[<type>\\]\\.","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/RouteProcessor.java","lineNumber":224,"sourceCode":"                    if (isActivity) {\n                        // Activity\n                        logger.info(\">>> Found activity route: \" + tm.toString() + \" <<<\");\n                        routeMeta = new RouteMeta(route, element, RouteType.ACTIVITY, paramsType);\n                    } else {\n                        // Fragment\n                        logger.info(\">>> Found fragment route: \" + tm.toString() + \" <<<\");\n                        routeMeta = new RouteMeta(route, element, RouteType.FRAGMENT, paramsType);\n                    }\n\n                    routeMeta.setInjectConfig(injectConfig);\n                } else if (isSubtypeOf(tm, iProvider)) {         // IProvider\n                    logger.info(\">>> Found provider route: \" + tm.toString() + \" <<<\");\n                    routeMeta = new RouteMeta(route, element, RouteType.PROVIDER, null);\n                } else if (isSubtypeOf(tm, type_Service)) {           // Service\n                    logger.info(\">>> Found service route: \" + tm.toString() + \" <<<\");\n                    routeMeta = new RouteMeta(route, element, RouteType.parse(SERVICE), null);\n                } else {\n                    throw new RuntimeException(\"The @Route is marked on unsupported class, look at [\" + tm.toString() + \"].\");\n                }\n\n                categories(routeMeta);\n            }\n\n            MethodSpec.Builder loadIntoMethodOfProviderBuilder = MethodSpec.methodBuilder(METHOD_LOAD_INTO)\n                    .addAnnotation(Override.class)\n                    .addModifiers(PUBLIC)\n                    .addParameter(providerParamSpec);\n\n            Map<String, List<RouteDoc>> docSource = new HashMap<>();\n\n            // Start generate java source, structure is divided into upper and lower levels, used for demand initialization.\n            for (Map.Entry<String, Set<RouteMeta>> entry : groupMap.entrySet()) {\n                String groupName = entry.getKey();\n\n                MethodSpec.Builder loadIntoMethodOfGroupBuilder = MethodSpec.methodBuilder(METHOD_LOAD_INTO)\n                        .addAnnotation(Override.class)","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/alibaba/ARouter/blob/84f451d244e3fb1d0e37801de1b9ee2af2f81d68/arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/RouteProcessor.java#L206-L242","documentation":"Thrown by RouteProcessor.parseRoutes when a class annotated with @Route is not a subtype of any supported route target: Activity, Fragment (androidx or support), IProvider, or Service. ARouter routes must point to a class it knows how to instantiate/navigate to, so compilation fails with the offending type name.","triggerScenarios":"Annotating an arbitrary class (e.g. a plain helper, ViewModel, BroadcastReceiver, or a Fragment from an unsupported superclass) with @Route so the type check chain (Activity → Fragment → IProvider → Service) exhausts all branches and hits the else throw.","commonSituations":"Annotating a BroadcastReceiver with @Route expecting router support; migrating support Fragment to a subclass not recognized; typo in class hierarchy after refactoring (e.g. extending a base class that no longer extends Fragment/Activity).","solutions":["Remove @Route from the unsupported class; navigate to it by other means.","Make the class extend a supported type (Activity, Fragment, Service, or implement IProvider).","If it is a service-like object, implement IProvider and use @Route(path = ...)."],"exampleFix":"// before\n@Route(path = \"/push/receiver\")\npublic class PushReceiver extends BroadcastReceiver { ... }\n\n// after (remove annotation)\npublic class PushReceiver extends BroadcastReceiver { ... }","handlingStrategy":"validation","validationCode":"Class<?> c = clazz;\nboolean supported = Activity.class.isAssignableFrom(c) || Fragment.class.isAssignableFrom(c)\n    || Service.class.isAssignableFrom(c) || IProvider.class.isAssignableFrom(c);\nif (clazz.isAnnotationPresent(Route.class) && !supported) {\n    throw new IllegalStateException(\"@Route on unsupported type: \" + clazz.getName());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only annotate Activity, Fragment, Service, or IProvider implementations.","Do not use @Route on BroadcastReceiver or plain classes.","After hierarchy refactors, verify base classes still extend supported Android types."],"tags":["annotation-processor","arouter","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"84f451d244e3fb1d0e37801de1b9ee2af2f81d68","analyzedAt":"2026-09-06T13:30:41.084Z","contentChangedAt":"2026-09-06T13:30:41.084Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}