alibaba/ARouter · error · IllegalArgumentException

More than one interceptors use same priority [%d], They are

Error message

More than one interceptors use same priority [%d], They are [%s] and [%s].

What it means

Thrown by InterceptorProcessor.parseInterceptors when two classes annotated with @Interceptor declare the same priority. ARouter interceptors are indexed by their priority in a map, so duplicate priorities are ambiguous and compilation fails, naming both conflicting classes.

Source

Thrown at arouter-compiler/src/main/java/com/alibaba/android/arouter/compiler/processor/InterceptorProcessor.java:95

    /**
     * Parse interceptor.
     *
     * @param elements elements of interceptor.
     */
    private void parseInterceptors(Set<? extends Element> elements) throws IOException {
        if (CollectionUtils.isNotEmpty(elements)) {
            logger.info(">>> Found interceptors, size is " + elements.size() + " <<<");

            // Verify and cache, sort incidentally.
            for (Element element : elements) {
                if (verify(element)) {  // Check the interceptor meta
                    logger.info("A interceptor verify over, its " + element.asType());
                    Interceptor interceptor = element.getAnnotation(Interceptor.class);

                    Element lastInterceptor = interceptors.get(interceptor.priority());
                    if (null != lastInterceptor) { // Added, throw exceptions
                        throw new IllegalArgumentException(
                                String.format(Locale.getDefault(), "More than one interceptors use same priority [%d], They are [%s] and [%s].",
                                        interceptor.priority(),
                                        lastInterceptor.getSimpleName(),
                                        element.getSimpleName())
                        );
                    }

                    interceptors.put(interceptor.priority(), element);
                } else {
                    logger.error("A interceptor verify failed, its " + element.asType());
                }
            }

            // Interface of ARouter.
            TypeElement type_IInterceptor = elementUtils.getTypeElement(IINTERCEPTOR);
            TypeElement type_IInterceptorGroup = elementUtils.getTypeElement(IINTERCEPTOR_GROUP);

            /**

View on GitHub (pinned to 84f451d244)

Solutions

  1. Change the priority of one of the conflicting @Interceptor classes to a unique value.
  2. Search the codebase for `@Interceptor(priority = <N>)` and assign distinct priorities.
  3. If the conflict is across modules, coordinate priority allocation across teams or document priority ranges per module.

Example fix

// before
@Interceptor(priority = 1)
public class LoginInterceptor implements IInterceptor { ... }
@Interceptor(priority = 1)
public class LogInterceptor implements IInterceptor { ... }

// after
@Interceptor(priority = 1)
public class LoginInterceptor implements IInterceptor { ... }
@Interceptor(priority = 2)
public class LogInterceptor implements IInterceptor { ... }
Defensive patterns

Strategy: validation

Validate before calling

// CI check: ensure unique interceptor priorities
Set<Integer> seen = new HashSet<>();
for (Class<?> c : interceptorClasses) {
    int p = c.getAnnotation(Interceptor.class).priority();
    if (!seen.add(p)) throw new IllegalStateException("Duplicate interceptor priority: " + p);
}

Prevention

When it happens

Trigger: Two @Interceptor(priority = N) classes in the same module (or across modules compiled together) share the same integer N, and the second insert into interceptors.get(priority) finds an existing entry.

Common situations: Copy-pasting an interceptor class and forgetting to change the priority; two teams adding interceptors with the same priority in different modules; refactoring that merges modules.

Related errors


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