shwenzhang/AndResGuard · error · OptionsException
Unsupported value for
Error message
Unsupported value for <mLastOptionOriginalForm>: <stringValue>. Only true or false supported.
What it means
A boolean-valued option was given something other than the literal strings "true" or "false". The parser only accepts exact lowercase matches and rejects everything else — including "True", "1", "0", "yes", or an empty string — with an OptionsException listing the accepted values.
Solutions
- Use the exact lowercase literals: `--v2-signing-enabled true` or `--v2-signing-enabled false`.
- Normalize values in scripts: lowercase and map 1/0 or yes/no to true/false before invoking apksigner.
- Ensure the variable providing the value is set and non-empty.
- Omit the option entirely if you want the default behavior instead of guessing a value.
Example fix
// before apksigner sign --v2-signing-enabled True --out app.apk in.apk // after apksigner sign --v2-signing-enabled true --out app.apk in.apk
Defensive patterns
Strategy: validation
Validate before calling
static String normalizeBoolean(String raw) {
if (raw == null) return "false";
String v = raw.trim().toLowerCase(java.util.Locale.ROOT);
if (v.equals("1") || v.equals("yes") || v.equals("y")) return "true";
if (v.equals("0") || v.equals("no") || v.equals("n")) return "false";
if (v.equals("true") || v.equals("false")) return v;
throw new IllegalArgumentException("Value must be true or false (got: " + raw + ")");
}
// usage: args.add("--v2-signing-enabled"); args.add(normalizeBoolean(env("V2_SIGNING"))); Try / catch
try {
apksignerSign(args);
} catch (OptionsException e) {
if (e.getMessage().contains("Only true or false supported")) {
System.err.println("Boolean flags accept exactly 'true' or 'false' (lowercase): " + e.getMessage());
}
throw e;
} Prevention
- Use exactly the lowercase literals true/false — not True, 1, 0, yes, or no.
- Normalize CI/env boolean conventions (1/0, yes/no) before passing them to apksigner.
- Guard against empty expansions: ": \"${FLAG:?not set}\"".
- Prefer omitting boolean flags to get library defaults rather than inventing values.
- Sanitize with trim().toLowerCase() on any user-supplied boolean input.
When it happens
Trigger: Passing `--v2-signing-enabled True`, `--v1-signing-enabled 1`, `--enabled yes`, or an empty value (`--v3-signing-enabled` followed by nothing/expanding to empty) to a boolean option such as --v1-signing-enabled, --v2-signing-enabled, or --v3-signing-enabled.
Common situations: Shell variables holding "1"/"0" from CI configs; capitalized booleans from other tools' conventions; YAML/env-style "yes"/"no" values; a variable expanding to empty because the feature flag was unset.
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
- missing after
- Missing APK
- Unexpected parameter(s) after APK (<params[1]>)
- --ks and --key may not be specified at the same time
- --ks and --cert may not be specified at the same time
AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12).
Data as JSON: /api/errors/8ae5d395bddfab1e.
Report an issue: GitHub.
Appendix: source
Thrown at AndResGuard-core/src/main/java/apksigner/OptionsParser.java:150
+ value);
}
}
/**
* Gets the value of the current boolean option. Boolean options are not required to have
* explicitly specified values.
*/
public boolean getOptionalBooleanValue(boolean defaultValue) throws OptionsException {
if (mLastOptionValue != null) {
// --option=value form
String stringValue = mLastOptionValue;
mLastOptionValue = null;
if ("true".equals(stringValue)) {
return true;
} else if ("false".equals(stringValue)) {
return false;
}
throw new OptionsException("Unsupported value for "
+ mLastOptionOriginalForm
+ ": "
+ stringValue
+ ". Only true or false supported.");
}
// --option (true|false) form OR just --option
if (mIndex >= mParams.length) {
return defaultValue;
}
String stringValue = mParams[mIndex];
if ("true".equals(stringValue)) {
mIndex++;
return true;
} else if ("false".equals(stringValue)) {
mIndex++;
return false;View on GitHub (pinned to e4df245d82)