alibaba/ARouter · error · RuntimeException

The @Route is marked on unsupported class, look at [<type>].

Error message

The @Route is marked on unsupported class, look at [<type>].

What it means

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.

Source

Thrown at arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/RouteProcessor.java:224

                    if (isActivity) {
                        // Activity
                        logger.info(">>> Found activity route: " + tm.toString() + " <<<");
                        routeMeta = new RouteMeta(route, element, RouteType.ACTIVITY, paramsType);
                    } else {
                        // Fragment
                        logger.info(">>> Found fragment route: " + tm.toString() + " <<<");
                        routeMeta = new RouteMeta(route, element, RouteType.FRAGMENT, paramsType);
                    }

                    routeMeta.setInjectConfig(injectConfig);
                } else if (isSubtypeOf(tm, iProvider)) {         // IProvider
                    logger.info(">>> Found provider route: " + tm.toString() + " <<<");
                    routeMeta = new RouteMeta(route, element, RouteType.PROVIDER, null);
                } else if (isSubtypeOf(tm, type_Service)) {           // Service
                    logger.info(">>> Found service route: " + tm.toString() + " <<<");
                    routeMeta = new RouteMeta(route, element, RouteType.parse(SERVICE), null);
                } else {
                    throw new RuntimeException("The @Route is marked on unsupported class, look at [" + tm.toString() + "].");
                }

                categories(routeMeta);
            }

            MethodSpec.Builder loadIntoMethodOfProviderBuilder = MethodSpec.methodBuilder(METHOD_LOAD_INTO)
                    .addAnnotation(Override.class)
                    .addModifiers(PUBLIC)
                    .addParameter(providerParamSpec);

            Map<String, List<RouteDoc>> docSource = new HashMap<>();

            // Start generate java source, structure is divided into upper and lower levels, used for demand initialization.
            for (Map.Entry<String, Set<RouteMeta>> entry : groupMap.entrySet()) {
                String groupName = entry.getKey();

                MethodSpec.Builder loadIntoMethodOfGroupBuilder = MethodSpec.methodBuilder(METHOD_LOAD_INTO)
                        .addAnnotation(Override.class)

View on GitHub (pinned to 84f451d244)

Solutions

  1. Remove @Route from the unsupported class; navigate to it by other means.
  2. Make the class extend a supported type (Activity, Fragment, Service, or implement IProvider).
  3. If it is a service-like object, implement IProvider and use @Route(path = ...).

Example fix

// before
@Route(path = "/push/receiver")
public class PushReceiver extends BroadcastReceiver { ... }

// after (remove annotation)
public class PushReceiver extends BroadcastReceiver { ... }
Defensive patterns

Strategy: validation

Validate before calling

Class<?> c = clazz;
boolean supported = Activity.class.isAssignableFrom(c) || Fragment.class.isAssignableFrom(c)
    || Service.class.isAssignableFrom(c) || IProvider.class.isAssignableFrom(c);
if (clazz.isAnnotationPresent(Route.class) && !supported) {
    throw new IllegalStateException("@Route on unsupported type: " + clazz.getName());
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06). Data as JSON: /api/errors/4ee70644d06a62f8. Report an issue: GitHub.