pxb1988/dex2jar · error · DexException
while accept method:[ ]
Error message
while accept method:[%s]
What it means
Outermost wrapper in DexFileReader.acceptMethod: any exception raised while visiting a method (annotations, code, or the visitor callbacks themselves) is wrapped in DexException("while accept method:[%s]") naming the method. It is the last resort, so the cause chain already contains more specific wrappers like 'while accept code'.
Solutions
- Walk the cause chain to find the specific inner error (code, annotation, etc.)
- Catch DexException per-method in your conversion loop to skip broken methods
- Validate/rebuild the dex with the official toolchain
- Update d2j to the latest version for broader opcode/feature support
Example fix
// before
reader.accept(dmv);
// after
try {
reader.accept(dmv);
} catch (DexException e) {
Throwable root = e; while (root.getCause() != null) root = root.getCause();
System.err.println("skipped method: " + e.getMessage() + " / " + root);
} Defensive patterns
Strategy: try-catch
Try / catch
try {
reader.accept(dmv);
} catch (DexException e) {
Throwable root = e;
while (root.getCause() != null) root = root.getCause();
logger.warn("method skipped: " + e.getMessage(), root);
} Prevention
- Always log the full cause chain, not just the top message
- Process methods individually so one failure doesn't abort the batch
- Validate dex files with dexlint/dexdump before conversion
When it happens
Trigger: accept(DexMethodVisitor) invoked on a method whose annotation, code, or visitor callbacks throw any Exception.
Common situations: Bulk dex-to-java conversion where one bad method aborts the whole file; users see only this top-level message unless they inspect the cause chain.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- while accept parameter annotation in method
- while accept code in method
- While accepting parameter annotation in parameter
- Odex unsupported.
- Magic unsupported.
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/469636dcd0a2fd3e.
Report an issue: GitHub.
Appendix: source
Thrown at dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java:1076
keep = 0 != (KEEP_CLINIT & config) && method.getName().equals("<clinit>");
}
if(keep) {
DexCodeVisitor dcv = dmv.visitCode();
if (dcv != null) {
try {
acceptCode(code_off, dcv, config, (method_access_flags & DexConstants.ACC_STATIC) != 0,
method);
} catch (Exception e) {
throw new DexException(e, "while accept code in method:[%s] @%08x", method.toString(),
code_off);
}
}
}
}
dmv.visitEnd();
}
} catch (Exception e) {
throw new DexException(e, "while accept method:[%s]", method.toString());
}
return method_id;
}
private void read_annotation_set_ref_list(int parameter_annotation_offset, DexMethodVisitor dmv) {
ByteBuffer in = annotationSetRefListIn;
in.position(parameter_annotation_offset);
int size = in.getInt();
for (int j = 0; j < size; j++) {
int param_annotation_offset = in.getInt();
if (param_annotation_offset == 0) {
continue;
}
DexAnnotationAble dpav = dmv.visitParameterAnnotation(j);
try {
if (dpav != null) {
View on GitHub (pinned to b5bda4fb49)