{"record":{"id":"c44049350f36bdf3","repo":"skylot/jadx","slug":"failed-to-decode-insn","errorCode":null,"errorMessage":"Failed to decode insn: {}","messagePattern":"Failed to decode insn: (.+?)","errorType":"exception","errorClass":"JadxRuntimeException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java","lineNumber":57,"sourceCode":"\tpublic InsnDecoder(MethodNode mthNode) {\n\t\tthis.method = mthNode;\n\t\tthis.root = method.root();\n\t}\n\n\tpublic InsnNode[] process(ICodeReader codeReader) {\n\t\tInsnNode[] instructions = new InsnNode[codeReader.getUnitsCount()];\n\t\tcodeReader.visitInstructions(rawInsn -> {\n\t\t\tint offset = rawInsn.getOffset();\n\t\t\tInsnNode insn;\n\t\t\ttry {\n\t\t\t\trawInsn.decode();\n\t\t\t\tinsn = decode(rawInsn);\n\t\t\t} catch (Exception e) {\n\t\t\t\tboolean mthWithErrors = method.contains(AType.JADX_ERROR);\n\t\t\t\tmethod.addError(\"Failed to decode insn: \" + rawInsn, e);\n\t\t\t\tif (mthWithErrors) {\n\t\t\t\t\t// second error in this method => abort processing\n\t\t\t\t\tthrow new JadxRuntimeException(\"Failed to decode insn: \" + rawInsn, e);\n\t\t\t\t}\n\t\t\t\tinsn = new InsnNode(InsnType.NOP, 0);\n\t\t\t\tinsn.addAttr(AType.JADX_ERROR, new JadxError(\"decode failed: \" + e.getMessage(), e));\n\t\t\t}\n\t\t\tinsn.setOffset(offset);\n\t\t\tinstructions[offset] = insn;\n\t\t});\n\t\treturn instructions;\n\t}\n\n\tprotected InsnNode decode(InsnData insn) throws DecodeException {\n\t\tswitch (insn.getOpcode()) {\n\t\t\tcase NOP:\n\t\t\t\treturn new InsnNode(InsnType.NOP, 0);\n\n\t\t\t// move-result will be process in invoke and filled-new-array instructions\n\t\t\tcase MOVE_RESULT:\n\t\t\t\treturn insn(InsnType.MOVE_RESULT, InsnArg.reg(insn, 0, ArgType.UNKNOWN));","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/instructions/InsnDecoder.java#L39-L75","documentation":"Thrown when a SECOND instruction fails to decode within the same method. InsnDecoder.process() tolerates the first failure (records a soft JadxError on a NOP placeholder), but on a second failure it aborts method processing by re-throwing as JadxRuntimeException. This propagates up to MethodNode.load(), which catches it, reloads the method without code, and re-wraps as DecodeException.","triggerScenarios":"Decoding a DEX method whose bytecode contains two or more unparseable instructions. The first decode error sets AType.JADX_ERROR on the method (mthWithErrors check at line 53); the second hits the 'abort' branch at line 57.","commonSituations":"Heavily obfuscated APKs, DEX emitted by novel/buggy compilers or packers, truncated DEX code sections, or APKs targeting a newer Android API level whose opcode patterns the installed JADX release does not yet handle.","solutions":["Upgrade JADX to the latest release — newer versions decode more opcode patterns and obfuscation tricks.","Run jadx with --show-bad-code to emit partial output despite per-instruction decode failures.","Re-extract the APK from a clean source to rule out download/transfer corruption.","Report the class/method and full stack trace to the JADX issue tracker for the unhandled bytecode shape."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Decompile class-by-class so one method's decode failure does not abort the whole run.\nfor (JavaClass cls : jadx.getClasses()) {\n    try {\n        String code = cls.getCode();\n    } catch (JadxRuntimeException | DecodeException e) {\n        log.warn(\"Decode failed for class {}, skipping\", cls.getClassNode().getClassInfo(), e);\n    }\n}","preventionTips":["Keep JADX on the latest release for the broadest bytecode coverage.","Use --show-bad-code to tolerate per-instruction decode errors and retain partial output.","Decompile in per-class try/catch loops when scripting so one failure does not stop the batch."],"tags":["dex-decode","bytecode","malformed-input","obfuscation"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}