pxb1988/dex2jar · error · HelpException

ERROR: Options: is required

Error message

ERROR: Options: ${options} is required

What it means

BaseCmd's argument parser (parseSetArgs) collects required command-line options before dispatching to a subcommand. When one or more options marked as required are absent from the parsed command line, it prints the full list of missing options to stderr and throws HelpException. This is the library's standard way of aborting with usage help instead of proceeding with incomplete configuration.

Solutions

  1. Run the command with no arguments or -h to print usage and see which options are required.
  2. Add the missing option(s) listed in the stderr message, e.g. d2j-dex2jar.sh -o out.jar in.apk.
  3. Check for typos in option names; unknown options are dropped, leaving required ones unsatisfied.
  4. If invoking programmatically, pass options through BaseCmd.doMain with the correct -opt value pairs.
  5. If the requirement changed in a newer dex2jar release, update wrapper scripts to supply the new required option.

Example fix

// before
d2j-dex2jar.sh classes.dex -f
// (missing required -o)

// after
d2j-dex2jar.sh -f -o classes-dex2jar.jar classes.dex
Defensive patterns

Strategy: validation

Validate before calling

// Check required options before invoking the tool
String[] args = {"-f"}; // missing -o
boolean hasOutput = java.util.Arrays.asList(args).contains("-o");
if (!hasOutput) {
    System.err.println("Required option -o <output> is missing; see tool usage.");
    return;
}

Try / catch

try {
    MyCmd.doMain(args);
} catch (com.googlecode.dex2jar.tools.BaseCmd.HelpException e) {
    // usage already printed to stderr; show help and exit non-zero
    System.exit(2);
}

Prevention

When it happens

Trigger: Running a dex2jar tool command (e.g. d2j-dex2jar.sh, d2j-jar2dex) via BaseCmd.doMain without supplying a mandatory option such as the input/output file, e.g. omitting -f/--force style required flags or forgetting the input dex/jar argument.

Common situations: Typing the command with too few arguments, wrapping an old wrapper script that passes stale flags, forgetting an option that was newly made required in a version update, or misplacing the argument so it is not attached to the required option.

Understand the failure class

Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.

Related errors


AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08). Data as JSON: /api/errors/07df8abe0ed4b1b6. Report an issue: GitHub.

Appendix: source

Thrown at d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java:478

        this.remainingArgs = remainsOptions.toArray(new String[0]);
        if (this.printHelp) {
            throw new HelpException();
        }
        if (!requiredOpts.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            sb.append("ERROR: Options: ");
            boolean first = true;
            for (Option option : requiredOpts) {
                if (first) {
                    first = false;
                } else {
                    sb.append(" and ");
                }
                sb.append(option.getOptAndLongOpt());
            }
            sb.append(" is required");
            System.err.println(sb);
            throw new HelpException();
        }

    }

    protected void usage() {
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.err, StandardCharsets.UTF_8), true);

        final int maxLength = 80;
        final int maxPaLength = 40;
        out.println(this.cmdName + " -- " + desc);
        out.println("usage: " + this.cmdName + " " + cmdLineSyntax);
        if (this.optMap.size() > 0) {
            out.println("options:");
        }
        // [PART.A.........][Part.B
        // .-a,--aa.<arg>...desc1
        // .................desc2
        // .-b,--bb

View on GitHub (pinned to b5bda4fb49)