pxb1988/dex2jar · error · HelpException
ERROR: Unrecognized option
Error message
ERROR: Unrecognized option: ${s} What it means
parseSetArgs walks the command-line arguments using the @Opt-annotated fields of the tool class; when an argument starting with '-' is not found in the option map it prints this ERROR line and throws HelpException, which makes the tool print usage and exit. It is the standard 'unknown option' rejection.
Solutions
- Run the tool with -h/--help to see the exact supported options
- Fix the option spelling to one shown in help (mind short vs long form)
- Check the dex2jar version - options change between releases; consult the matching documentation
- If passing a negative-looking value, ensure it is attached to its option (e.g. --key=-1) rather than starting a new token
Example fix
// before ./d2j-dex2jar.sh app.apk --output-file out.jar // after ./d2j-dex2jar.sh app.apk --output out.jar
Defensive patterns
Strategy: validation
Validate before calling
// pre-validate option names against help/known options
const KNOWN = ['-f','--force','-o','--output','-h','--help'];
for (const a of args) if (a.startsWith('-') && !KNOWN.includes(a)) throw new Error('Unknown option: '+a); Try / catch
try {
tool.doMain(args);
} catch (BaseCmd.HelpException e) {
// tool already printed 'ERROR: Unrecognized option: X' + usage; fix args and retry
} Prevention
- Copy option names from -h/--help output, not from memory or other tools
- Distinguish short (-o) vs long (--output) forms as registered by the tool
- Version-pin dex2jar in CI scripts and re-check options after upgrades
- Put '--' style values carefully; avoid stray leading '-' tokens in scripts
When it happens
Trigger: Invoking a dex2jar tool (doMain -> parseSetArgs) with an option name that is not registered, e.g. a typo like --output-file instead of -o/--output, an option from a different tool, or an option removed in a newer dex2jar version.
Common situations: Copy-pasting CLI invocations from tutorials for other tools/versions; short/long option confusion (this parser does not accept single-dash long forms other than registered ones); typos like -force vs --force; a combining prefix such as '-' consumed from a leading '-' value.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- ERROR: Option need an argument value
- can't convert [ ] to type
- ERROR: Options: is required
- -cv,--class-version out of range, 1-18 is supported.
- version not support yet!
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/454ea7086cf6e110.
Report an issue: GitHub.
Appendix: source
Thrown at d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java:443
m.invoke(null, (Object)newArgs);
}
}
protected void parseSetArgs(String... args) throws IllegalArgumentException, IllegalAccessException {
this.originalArgs = args;
List<String> remainsOptions = new ArrayList<>();
Set<Option> requiredOpts = collectRequiredOptions(optMap);
Option needArgOpt = null;
for (String s : args) {
if (needArgOpt != null) {
needArgOpt.field.set(this, convert(s, needArgOpt.field.getType()));
needArgOpt = null;
} else if (s.startsWith("-")) {// it's a short or long option
Option opt = optMap.get(s);
requiredOpts.remove(opt);
if (opt == null) {
System.err.println("ERROR: Unrecognized option: " + s);
throw new HelpException();
} else {
if (opt.hasArg) {
needArgOpt = opt;
} else {
opt.field.set(this, true);
}
}
} else {
remainsOptions.add(s);
}
}
if (needArgOpt != null) {
System.err.println("ERROR: Option " + needArgOpt.getOptAndLongOpt() + " need an argument value");
throw new HelpException();
}
this.remainingArgs = remainsOptions.toArray(new String[0]);
if (this.printHelp) {View on GitHub (pinned to b5bda4fb49)