alibaba/ARouter · error · HandlerException
Extract the default group failed! There's nothing between 2
Error message
Extract the default group failed! There's nothing between 2 '/'!
What it means
When the path starts with '/' but has no second '/' (or nothing between the two slashes), extractGroup cannot produce a group name. The code attempts substring extraction and throws HandlerException for the empty-group case; note the surrounding catch logs a warning and returns null for other parse failures, which then triggers the 'Parameter is invalid' error in build(path, group, ...).
Source
Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java:251
} catch (HandlerException invalidPath) {
return false;
}
return LogisticsCenter.hasRoute(postcard);
}
/**
* Extract the default group from path.
*/
private String extractGroup(String path) {
if (TextUtils.isEmpty(path) || !path.startsWith("/")) {
throw new HandlerException(Consts.TAG + "Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!");
}
try {
String defaultGroup = path.substring(1, path.indexOf("/", 1));
if (TextUtils.isEmpty(defaultGroup)) {
throw new HandlerException(Consts.TAG + "Extract the default group failed! There's nothing between 2 '/'!");
} else {
return defaultGroup;
}
} catch (Exception e) {
logger.warning(Consts.TAG, "Failed to extract default group! " + e.getMessage());
return null;
}
}
static void afterInit() {
// Trigger interceptor init, use byName.
interceptorService = (InterceptorService) ARouter.getInstance().build("/arouter/service/interceptor").navigation();
}
protected <T> T navigation(Class<? extends T> service) {
try {
Postcard postcard = LogisticsCenter.buildProvider(service.getName());
View on GitHub (pinned to 84f451d244)
Solutions
- Use two-segment paths: '/group/name' (e.g. '/app/main' instead of '/main')
- Re-register the @Route(path) annotations with a proper group segment
- Add a path normalizer (PathReplaceService) that inserts a default group for single-segment paths
- Check for accidental double slashes in configured paths
Example fix
// before @Route(path = "/main") // no group segment public class MainActivity ... // after @Route(path = "/app/main") // group 'app', path 'main' public class MainActivity ...
Defensive patterns
Strategy: validation
Validate before calling
public static boolean hasGroupSegment(String path) {
if (path == null || !path.startsWith("/")) return false;
int second = path.indexOf('/', 1);
return second > 1; // non-empty group between slashes
} Try / catch
try {
ARouter.getInstance().build(path).navigation();
} catch (HandlerException e) {
Log.w(TAG, "Path missing group segment", e);
} Prevention
- Register every @Route with '/group/name', never single-segment paths
- Add a PathReplaceService to map legacy single-segment paths
- Grep CI for @Route(path = "/x") single-segment registrations
When it happens
Trigger: Calling build("/login") — starts with '/' but no second segment — or build("//detail") with nothing between the slashes.
Common situations: Paths registered without a group prefix; single-segment paths like "/main"; migrating from another router library that allowed single-segment paths.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Extract the default group failed, the path must be start wit
- ARouter::Init::Invoke init(context) first!
- ARouterCore::Init::Invoke init(context) first!
- Parameter is invalid!
- Parameter invalid!
AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06).
Data as JSON: /api/errors/3108b8b0ed3c4e48.
Report an issue: GitHub.