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

  1. Use the exact lowercase literals: `--v2-signing-enabled true` or `--v2-signing-enabled false`.
  2. Normalize values in scripts: lowercase and map 1/0 or yes/no to true/false before invoking apksigner.
  3. Ensure the variable providing the value is set and non-empty.
  4. 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

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


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)