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
- Change the priority of one of the conflicting @Interceptor classes to a unique value.
- Search the codebase for `@Interceptor(priority = <N>)` and assign distinct priorities.
- 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
- Keep a central registry/doc of allocated interceptor priorities.
- When copying an interceptor, immediately change its priority.
- Add a unit test scanning @Interceptor annotations for duplicate priorities.
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
- String.format(tipText, key)
- Interceptor timeout has already been scheduled.
- Interceptor initialization failure must have a cause.
- TimeUnit must not be null.
- The fields need autowired from intent, its parent must be ac
AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06).
Data as JSON: /api/errors/2d96ecd6c109f19d.
Report an issue: GitHub.