MuntashirAkon/AppManager · error
Error! debug must be either 0 or 1.\n
Error message
Error! debug must be either 0 or 1.\n
What it means
Validation guard in main(): the 8th command-line argument (debug flag) passed to this native server launcher is neither "0" nor "1". The C entry point refuses to proceed so downstream app_process calls never run with an ambiguous debug setting; the faulting input is argv[7].
Source
Thrown at app/src/main/cpp/run_server.c:98
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");
return 1;
}
// Validate debug and bgrun
if ((strcmp(debug, "0") != 0 && strcmp(debug, "1") != 0)) {
fprintf(stderr, "Error! debug must be either 0 or 1.\n");
return 1;
}
// /data/local/tmp/am.jar
char exec_jar_path[512];
if (snprintf(exec_jar_path, sizeof(exec_jar_path), "%s/%s", TMP_PATH, am_jar_name) >=
sizeof(exec_jar_path)) {
fprintf(stderr, "Error! Buffer overflow on exec_jar_path.\n");
return 1;
}
// /data/local/tmp/main.jar
char main_jar_path[512];
if (snprintf(main_jar_path, sizeof(main_jar_path), "%s/%s", TMP_PATH, main_jar_name) >=
sizeof(main_jar_path)) {
fprintf(stderr, "Error! Buffer overflow on main_jar_path.\n");
return 1;
}View on GitHub (pinned to 0152f468fc)
Solutions
- Pass debug strictly as "0" or "1" from the launcher
- Convert booleans on the caller side with (debug ? "1" : "0")
- If arguments were shifted, fix the argument order/count first (see the argc<8 usage error)
Example fix
// before ... + " " + debugFlag; // debugFlag = true // after ... + " " + (debugFlag ? "1" : "0");
Defensive patterns
Strategy: validation
Validate before calling
if (!("0".equals(debug) || "1".equals(debug)))
throw new IllegalArgumentException("debug must be 0 or 1"); Prevention
- Serialize booleans as "1"/"0" with a single helper
- Never pass raw boolean types into argv concatenation
- Check argument order when adding new parameters
When it happens
Trigger: argv[7] != "0" and != "1" — e.g. caller passed "true"/"false", "debug", "01", or an empty string.
Common situations: Caller formats a boolean as true/false instead of 1/0; string concatenation introduces a space; an extra/missing earlier argument shifts positions so argv[7] holds the wrong value.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- USAGE: %s <port> <token> <am_jar_name> <main_jar_name> <app_
- Error! Invalid characters in arguments.\n
- Unknown density {densityName}
- Package name is missing.
- No splits selected.
AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12).
Data as JSON: /api/errors/260b29ec97c531cf.
Report an issue: GitHub.