pxb1988/dex2jar · error · HelpException
Only one file is required, But we found
Error message
Only one <jar> file is required, But we found
What it means
Command-line validation in doCommandLine of DecryptStringCmd: more than one positional argument was supplied. The tool decrypts strings in exactly one jar, so any extra positional arguments trigger this HelpException (which normally prints usage) — it is a usage error, not a processing failure.
Solutions
- Provide exactly one jar per invocation; loop in a shell script for multiple jars
- Quote paths containing spaces so they count as a single argument
- Remove stray tokens after the jar argument
Example fix
// before d2j-decrypt-string a.jar b.jar // after d2j-decrypt-string a.jar && d2j-decrypt-string b.jar
Defensive patterns
Strategy: validation
Validate before calling
if (args.stream().filter(a -> !a.startsWith("-")).count() > 1)
throw new IllegalArgumentException("pass exactly one jar"); Try / catch
try { DecryptStringCmd.main(args); } catch (HelpException e) { System.err.println(e.getMessage()); System.exit(2); } Prevention
- Process multiple jars with a loop, one invocation each
- Quote paths containing spaces
- Verify final positional args count equals 1 before invoking
When it happens
Trigger: Running d2j-decrypt-string with two or more positional jar paths, or stray unquoted tokens on the command line being counted as remainingArgs.
Common situations: Trying to process multiple jars in one run, or an accidental extra token (unquoted path with spaces) after the jar name.
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
- One file is required
- can't convert [ ] to type
- ERROR: Unrecognized option
- ERROR: Option need an argument value
- ERROR: Options: is required
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/c56b1053c455457c.
Report an issue: GitHub.
Appendix: source
Thrown at dex-tools/src/main/java/com/googlecode/dex2jar/tools/DecryptStringCmd.java:160
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) {
System.err.println(output + " exists, use --force to overwrite");
return;View on GitHub (pinned to b5bda4fb49)