{"record":{"id":"454ea7086cf6e110","repo":"pxb1988/dex2jar","slug":"error-unrecognized-option-s","errorCode":null,"errorMessage":"ERROR: Unrecognized option: ${s}","messagePattern":"ERROR: Unrecognized option: (.+?)","errorType":"console","errorClass":"HelpException","httpStatus":null,"severity":"error","filePath":"d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java","lineNumber":443,"sourceCode":"            m.invoke(null, (Object)newArgs);\n        }\n    }\n    \n    protected void parseSetArgs(String... args) throws IllegalArgumentException, IllegalAccessException {\n        this.originalArgs = args;\n        List<String> remainsOptions = new ArrayList<>();\n        Set<Option> requiredOpts = collectRequiredOptions(optMap);\n        Option needArgOpt = null;\n        for (String s : args) {\n            if (needArgOpt != null) {\n                needArgOpt.field.set(this, convert(s, needArgOpt.field.getType()));\n                needArgOpt = null;\n            } else if (s.startsWith(\"-\")) {// it's a short or long option\n                Option opt = optMap.get(s);\n                requiredOpts.remove(opt);\n                if (opt == null) {\n                    System.err.println(\"ERROR: Unrecognized option: \" + s);\n                    throw new HelpException();\n                } else {\n                    if (opt.hasArg) {\n                        needArgOpt = opt;\n                    } else {\n                        opt.field.set(this, true);\n                    }\n                }\n            } else {\n                remainsOptions.add(s);\n            }\n        }\n\n        if (needArgOpt != null) {\n            System.err.println(\"ERROR: Option \" + needArgOpt.getOptAndLongOpt() + \" need an argument value\");\n            throw new HelpException();\n        }\n        this.remainingArgs = remainsOptions.toArray(new String[0]);\n        if (this.printHelp) {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java#L425-L461","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n./d2j-dex2jar.sh app.apk --output-file out.jar\n// after\n./d2j-dex2jar.sh app.apk --output out.jar","handlingStrategy":"validation","validationCode":"// pre-validate option names against help/known options\nconst KNOWN = ['-f','--force','-o','--output','-h','--help'];\nfor (const a of args) if (a.startsWith('-') && !KNOWN.includes(a)) throw new Error('Unknown option: '+a);","typeGuard":null,"tryCatchPattern":"try {\n  tool.doMain(args);\n} catch (BaseCmd.HelpException e) {\n  // tool already printed 'ERROR: Unrecognized option: X' + usage; fix args and retry\n}","preventionTips":["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"],"tags":["cli","options","parsing","usage"],"backgroundTag":"invalid-cli-argument","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}