pxb1988/dex2jar · error · RuntimeException
can't convert [ ] to type
Error message
can't convert [${value}] to type ${type} What it means
convert() maps a raw command-line string to a typed field value; for enum-typed options it does Enum.valueOf(type, value) and, on any failure (bad constant, wrong type), throws a RuntimeException with this message. It is dex2jar's generic 'this option value is not valid for the target type' error.
Solutions
- Use the exact enum constant name with correct casing for that option
- Run the tool with -h/--help to list allowed values for the option
- Check the enum type named in the message (e.g. class com...Level) and pick one of its constants
- If scripting, match values against the enum in your wrapper script
Example fix
// before ./d2j-dex2jar.sh -f app.apk --log-level verbose // after ./d2j-dex2jar.sh -f app.apk --log-level DEBUG
Defensive patterns
Strategy: validation
Validate before calling
// validate enum option value before invoking
def validEnum(type, value) {
try { Enum.valueOf(type, value); return true } catch (e) { return false }
}
assert validEnum(com.googlecode.dex2jar.tools.Level.class, "DEBUG") Try / catch
try {
tool.doMain(args);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("can't convert [")) {
System.err.println("Bad option value; run with -h for allowed values");
} else throw e;
} Prevention
- Always match enum constants exactly, including casing
- Consult -h/--help output for the accepted value list of each option
- Quote enum-like values in shell scripts to avoid casing/spacing surprises
- Pin your scripts to a known dex2jar version since enum options can change
When it happens
Trigger: Passing a CLI option whose declared field is an enum type but whose value does not match any enum constant name (exact, case-sensitive match required), e.g. --log-level verbose when the enum defines only ERROR/WARN/INFO/DEBUG.
Common situations: Typo or wrong casing of enum constants; using a human-friendly value like 'warn' instead of 'WARN'; passing a number for an enum option; changes in enum constants between dex2jar versions.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- ERROR: Unrecognized option
- ERROR: Option need an argument value
- 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/78ac3b69dc69a236.
Report an issue: GitHub.
Appendix: source
Thrown at d2j-base-cmd/src/main/java/com/googlecode/dex2jar/tools/BaseCmd.java:279
if (type.equals(double.class) || type.equals(Double.class)) {
return Double.parseDouble(value);
}
if (type.equals(boolean.class) || type.equals(Boolean.class)) {
return Boolean.parseBoolean(value);
}
if (type.equals(File.class)) {
return new File(value);
}
if (type.equals(Path.class)) {
return new File(value).toPath();
}
try {
type.asSubclass(Enum.class);
return Enum.valueOf(type, value);
} catch (Exception ignored) {
}
throw new RuntimeException("can't convert [" + value + "] to type " + type);
}
protected abstract void doCommandLine() throws Exception;
public void doMain(String... args) {
try {
initOptions();
parseSetArgs(args);
doCommandLine();
} catch (HelpException e) {
String msg = e.getMessage();
if (msg != null && msg.length() > 0) {
System.err.println("ERROR: " + msg);
}
usage();
} catch (Exception e) {
e.printStackTrace(System.err);
}View on GitHub (pinned to b5bda4fb49)