pxb1988/dex2jar · error · HelpException

One file is required

Error message

One <jar> file is required

What it means

DecryptStringCmd requires exactly one input jar as its positional argument. When no arguments are given it throws HelpException("One <jar> file is required"), which prints command help instead of a stack trace.

Solutions

  1. Pass the target jar as the last positional argument
  2. Check that shell quoting/redirection didn't consume the argument
  3. Run with --help to see expected usage

Example fix

// before
d2j-decrypt-string -f key.txt
// after
d2j-decrypt-string -f key.txt app.jar
Defensive patterns

Strategy: validation

Validate before calling

if (args.length < 1) { System.err.println("Usage: d2j-decrypt-string [options] <jar>"); System.exit(1); }

Try / catch

try { DecryptStringCmd.main(args); } catch (HelpException e) { System.err.println(e.getMessage()); printUsage(); }

Prevention

When it happens

Trigger: Running d2j-decrypt-string (or invoking DecryptStringCmd.doCommandLine) with zero positional arguments after the flags.

Common situations: Forgetting the jar path, running with only flags like -f or -t, or quoting mistakes that swallow the argument in the shell.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java:158

        String name = line.substring(idx + 2, idx2);

        String desc = line.substring(idx2);
        if (desc.endsWith(")")) {
            desc = desc + "Ljava/lang/String;";
        }

        MethodConfig config = new MethodConfig();
        config.owner = owner;
        config.desc = desc;
        config.name = name;
        return config;

    }

    @Override
    protected void doCommandLine() throws Exception {
        if (remainingArgs.length == 0) {
            throw new HelpException("One <jar> file is required");
        } else if (remainingArgs.length > 1) {
            throw new HelpException("Only one <jar> file is required, But we found " + remainingArgs.length);
        }

        final Path jar = new File(remainingArgs[0]).toPath();
        if (!Files.exists(jar)) {
            System.err.println(jar + " doesn't exist");
            return;
        }
        if (output == null) {
            if (Files.isDirectory(jar)) {
                output = new File(jar.getFileName() + "-decrypted.jar").toPath();
            } else {
                output = new File(getBaseName(jar.getFileName().toString()) + "-decrypted.jar").toPath();
            }
        }

        if (Files.exists(output) && !forceOverwrite) {

View on GitHub (pinned to b5bda4fb49)