alibaba/ARouter · error · HandlerException
Parameter is invalid!
Error message
Parameter is invalid!
What it means
_ARouter.build(String path) throws HandlerException when the path argument is null or empty. A route path is mandatory to construct a Postcard, so the library validates it immediately before consulting PathReplaceService.
Source
Thrown at arouter-api/src/main/java/com/alibaba/android/arouter/launcher/_ARouter.java:184
static void setLogger(ILogger userLogger) {
if (null != userLogger) {
logger = userLogger;
}
}
static void inject(Object thiz) {
AutowiredService autowiredService = ((AutowiredService) ARouter.getInstance().build("/arouter/service/autowired").navigation());
if (null != autowiredService) {
autowiredService.autowire(thiz);
}
}
/**
* Build postcard by path and default group
*/
protected Postcard build(String path) {
if (TextUtils.isEmpty(path)) {
throw new HandlerException(Consts.TAG + "Parameter is invalid!");
} else {
PathReplaceService pService = ARouter.getInstance().navigation(PathReplaceService.class);
if (null != pService) {
path = pService.forString(path);
}
return build(path, extractGroup(path), true);
}
}
/**
* Build postcard by uri
*/
protected Postcard build(Uri uri) {
if (null == uri || TextUtils.isEmpty(uri.toString())) {
throw new HandlerException(Consts.TAG + "Parameter invalid!");
} else {
PathReplaceService pService = ARouter.getInstance().navigation(PathReplaceService.class);
if (null != pService) {View on GitHub (pinned to 84f451d244)
Solutions
- Validate the path is non-empty before calling build/hasRoute
- Log the source of the path (extra/config) to find why it is empty
- Provide a fallback route or early return when the path is blank
- If paths come through PathReplaceService, ensure the replacement doesn't return an empty string
Example fix
// before
String path = getIntent().getStringExtra("target");
ARouter.getInstance().build(path).navigation(); // HandlerException if empty
// after
String path = getIntent().getStringExtra("target");
if (!TextUtils.isEmpty(path)) {
ARouter.getInstance().build(path).navigation();
} else {
finish();
} Defensive patterns
Strategy: validation
Validate before calling
if (path == null || path.trim().isEmpty()) {
throw new IllegalArgumentException("route path must not be empty");
} Type guard
public static boolean isValidPath(String p) { return p != null && !p.trim().isEmpty(); } Try / catch
try {
ARouter.getInstance().build(path).navigation();
} catch (HandlerException e) {
Log.w(TAG, "Invalid route path", e);
} Prevention
- Validate paths sourced from configs/intents before building
- Never pass unchecked intent extras directly to build()
- Centralize navigation behind a wrapper that validates input
When it happens
Trigger: Calling ARouter.build("") or build(null) directly, or a hasRoute/isRouteExist call that forwards an empty path string (e.g. a path variable that resolved to empty).
Common situations: Path loaded from remote config, intent extra, or database that came back empty; string concatenation producing ""; typo passing the group instead of the full path.
Related errors
- Parameter invalid!
- The field '<fieldName>' is null, in class '<className>!
- ARouter::Init::Invoke init(context) first!
- ARouterCore::Init::Invoke init(context) first!
- Extract the default group failed, the path must be start wit
AI-assisted analysis of alibaba/ARouter@84f451d244 (2026-09-06).
Data as JSON: /api/errors/df47fdb75ecd1e77.
Report an issue: GitHub.