MuntashirAkon/AppManager · error
USAGE: %s <port> <token> <am_jar_name> <main_jar_name> <app_
Error message
USAGE: %s <port> <token> <am_jar_name> <main_jar_name> <app_id> <user_id> <debug(1|0)> [extra_args...]\n
What it means
The process was launched with fewer than the 8 mandatory arguments required by run_server (program name plus port, token, am_jar_name, main_jar_name, app_id, user_id, debug). The native server binary refuses to start without the full launch contract supplied by the caller (typically the Android app spawning it via exec).
Source
Thrown at app/src/main/cpp/run_server.c:74
while ((n = read(fd_src, buf, sizeof(buf))) > 0) {
if (write(fd_dst, buf, n) != n) {
// Write failed
close(fd_src);
close(fd_dst);
unlink(dst);
return -1;
}
}
close(fd_src);
close(fd_dst);
return (n < 0) ? -1 : 0;
}
int main(int argc, char *argv[]) {
if (argc < 8) {
fprintf(stderr,
"USAGE: %s <port> <token> <am_jar_name> <main_jar_name> <app_id> <user_id> <debug(1|0)> [extra_args...]\n",
argv[0]);
return 1;
}
const char *port = argv[1];
const char *token = argv[2];
const char *am_jar_name = argv[3];
const char *main_jar_name = argv[4];
const char *app_id = argv[5];
const char *user_id = argv[6];
const char *debug = argv[7];
const char *bgrun = "1";
// Validate Paths
if (!is_safe_string(am_jar_name) || !is_safe_string(main_jar_name) || !is_safe_string(app_id) ||
!is_safe_string(user_id)) {
fprintf(stderr, "Error! Invalid characters in arguments.\n");View on GitHub (pinned to 0152f468fc)
Solutions
- Fix the launcher (Runtime.exec/ProcessBuilder or C wrapper) to pass all 7 arguments in order: port, token, am_jar_name, main_jar_name, app_id, user_id, debug
- Add an argument-count check on the caller side before exec'ing the binary
- Rebuild/redeploy both the native binary and the app so both sides agree on the argument contract
Example fix
// before
Process p = Runtime.getRuntime().exec(new String[]{"su","-c",binary});
// after
Process p = Runtime.getRuntime().exec(new String[]{"su","-c",binary+" "+port+" "+token+" "+amJarName+" "+mainJarName+" "+appId+" "+userId+" "+(debug?1:0)}); Defensive patterns
Strategy: validation
Validate before calling
String[] args = {port, token, amJar, mainJar, appId, userId, debug ? "1" : "0"};
if (args.length < 7 || Arrays.stream(args).anyMatch(a -> a == null || a.isEmpty()))
throw new IllegalStateException("run_server requires 7 arguments"); Prevention
- Keep the argument list in one shared constant/builder used by all launch sites
- Log the full argv before exec to spot missing slots early
- Add a smoke test that execs the binary with dummy args and asserts it passes the usage check
When it happens
Trigger: main() is invoked with argc < 8, i.e. one or more of the required positional arguments port/token/am_jar_name/main_jar_name/app_id/user_id/debug is missing, or extra_args contains values that shift nothing but required slots were never filled.
Common situations: The spawning Android code builds the exec argv array incorrectly (misses an argument or passes null); an updated binary added a new required parameter while the app-side launcher was not rebuilt; a manual shell test on /data/local/tmp omits arguments.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- Error! Invalid characters in arguments.\n
- Error! debug must be either 0 or 1.\n
- Error! Buffer overflow on exec_jar_path.\n
- Error! Buffer overflow on main_jar_path.\n
- Error! %s could not be found or copied.\n
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/30d6a7044ffd42bd.
Report an issue: GitHub.