alibaba/ARouter · error · RuntimeException
String.format(tipText, key)
Error message
String.format(tipText, key)
What it means
UniqueKeyTreeMap is an internal ARouter map that guarantees unique keys for route/interceptor/provider indexing. put() throws a RuntimeException when the key already exists, formatting the map's tipText (an exception template like 'Path already registered, please check the repeated route!') with the duplicate key.
Source
Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/base/UniqueKeyTreeMap.java:24
* TreeMap with unique key.
*
* @author zhilong <a href="mailto:zhilong.lzl@alibaba-inc.com">Contact me.</a>
* @version 1.0
* @since 2017/2/22 下午5:01
*/
public class UniqueKeyTreeMap<K, V> extends TreeMap<K, V> {
private String tipText;
public UniqueKeyTreeMap(String exceptionText) {
super();
tipText = exceptionText;
}
@Override
public V put(K key, V value) {
if (containsKey(key)) {
throw new RuntimeException(String.format(tipText, key));
} else {
return super.put(key, value);
}
}
}
View on GitHub (pinned to 84f451d244)
Solutions
- Search the codebase for a duplicate @Route(path=...) value and rename one path uniquely
- Run gradle clean to purge stale generated ARouter group classes from old builds
- If two modules must share a path, unify it in one module and depend on it from the other
Example fix
// before
@Route(path = "/user/detail")
public class UserDetailActivity {...}
// (another module)
@Route(path = "/user/detail")
public class UserDetail2Activity {...}
// after
@Route(path = "/user/detail")
public class UserDetailActivity {...}
// (another module)
@Route(path = "/user/detail2")
public class UserDetail2Activity {...} Defensive patterns
Strategy: validation
Validate before calling
Set<String> seen = new HashSet<>();
for (RouteMeta m : allRouteMetas()) {
if (!seen.add(m.getPath())) {
throw new IllegalStateException("Duplicate route path registered: " + m.getPath());
}
} Try / catch
try {
arouter.init(application);
} catch (HandlerException e) {
if (e.getCause() instanceof RuntimeException && e.getMessage().contains("already registered")) {
Log.e(TAG, "Duplicate route path detected, see cause", e);
}
} Prevention
- Keep one owner per route path; centralize shared paths in a single module
- Run gradle clean after renaming/moving routes to purge stale generated classes
- Add a CI check that scans @Route annotations for duplicate paths
When it happens
Trigger: Registering two RouteMeta entries with the same path/class during Warehouse loading — e.g. two @Route(path="/x/y") annotations with the same path, duplicated route classes generated by the compiler plugin, or LogisticsCenter.init being run twice over the same class set.
Common situations: Two modules declare the same route path; a stale generated class from an old build is still on the classpath after refactoring a path; multi-module projects where different teams collide on a path prefix.
Related errors
- More than one interceptors use same priority [%d], They are
- Interceptor timeout has already been scheduled.
- Interceptor initialization failure must have a cause.
- TimeUnit must not be null.
- LogisticsCenterARouter init logistics center exception! [<fa
AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06).
Data as JSON: /api/errors/4822ff39e05d1aab.
Report an issue: GitHub.