shwenzhang/AndResGuard · error · ParameterException

Unexpected parameter(s) after

Error message

Unexpected parameter(s) after <optionOriginalForm>: <params[0]>

What it means

Validation in ApkSignerTool.sign: once the input APK path has been consumed from positional parameters, no further positional arguments are accepted. This throws when extra non-option tokens appear after --in (or after the signer options), typically a stray filename, typo, or option given without its leading '--'.

Solutions

  1. Remove the extra positional argument
  2. Use either --in <apk> or the positional APK path, not both
  3. Echo the final command in the script to spot duplicated args

Example fix

// before
apksigner sign --ks ks.jks --in app.apk app.apk
// after
apksigner sign --ks ks.jks --in app.apk
Defensive patterns

Strategy: validation

Validate before calling

if (usesInFlag(args) && positionalArgs(args).length > 0) throw new IllegalArgumentException("No positional args allowed after --in");

Try / catch

try { signCmd(args); } catch (ParameterException e) { System.err.println(e.getMessage()); exit(1); }

Prevention

When it happens

Trigger: `apksigner sign --ks ks.jks --in app.apk extra.apk` — a stray positional argument (often the APK path supplied twice, once via --in and once positionally).

Common situations: Scripts appending the APK path positionally while also using --in; pasted command lines with duplicated arguments; quoting errors leaving extra tokens.

Related errors


AI-assisted analysis of shwenzhang/AndResGuard@e4df245d82 (2026-09-12). Data as JSON: /api/errors/0c230b1f97e0f420. Report an issue: GitHub.

Appendix: source

Thrown at AndResGuard-core/src/main/java/apksigner/ApkSignerTool.java:198

                                     + ". See --help for supported"
                                     + " options.");
      }
    }
    if (!signerParams.isEmpty()) {
      signers.add(signerParams);
    }
    signerParams = null;

    if (signers.isEmpty()) {
      throw new ParameterException("At least one signer must be specified");
    }

    params = optionsParser.getRemainingParams();
    if (inputApk != null) {
      // Input APK has been specified via preceding parameters. We don't expect any more
      // parameters.
      if (params.length > 0) {
        throw new ParameterException("Unexpected parameter(s) after " + optionOriginalForm + ": " + params[0]);
      }
    } else {
      // Input APK has not been specified via preceding parameters. The next parameter is
      // supposed to be the path to input APK.
      if (params.length < 1) {
        throw new ParameterException("Missing input APK");
      } else if (params.length > 1) {
        throw new ParameterException("Unexpected parameter(s) after input APK (" + params[1] + ")");
      }
      inputApk = new File(params[0]);
    }
    if ((minSdkVersionSpecified) && (minSdkVersion > maxSdkVersion)) {
      throw new ParameterException("Min API Level (" + minSdkVersion + ") > max API Level (" + maxSdkVersion + ")");
    }

    List<ApkSigner.SignerConfig> signerConfigs = new ArrayList<>(signers.size());
    int signerNumber = 0;
    try (PasswordRetriever passwordRetriever = new PasswordRetriever()) {

View on GitHub (pinned to e4df245d82)