{"record":{"id":"525aa16dcfdb3de7","repo":"pxb1988/dex2jar","slug":"odex-unsupported","errorCode":null,"errorMessage":"Odex unsupported.","messagePattern":"Odex unsupported\\.","errorType":"exception","errorClass":"DexException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":162,"sourceCode":"    final int dex_version;\r\n\r\n    /**\r\n     * read dex from a {@link ByteBuffer}.\r\n     * \r\n     * @param in\r\n     */\r\n    public DexFileReader(ByteBuffer in) {\r\n        in.position(0);\r\n        in = in.asReadOnlyBuffer().order(ByteOrder.BIG_ENDIAN);\r\n        int magic = in.getInt() & 0xFFFFFF00;\r\n\r\n        final int MAGIC_DEX = 0x6465780A & 0xFFFFFF00;// hex for 'dex ', ignore the 0A\r\n        final int MAGIC_ODEX = 0x6465790A & 0xFFFFFF00;// hex for 'dey ', ignore the 0A\r\n\r\n        if (magic == MAGIC_DEX) {\r\n            // ok\r\n        } else if (magic == MAGIC_ODEX) {\r\n            throw new DexException(\"Odex unsupported.\");\r\n        } else {\r\n            throw new DexException(\"Magic unsupported.\");\r\n        }\r\n        int version = in.getInt() >> 8;\r\n        if (version < DEX_035 || version > DEX_040) {\r\n            System.err.println(\"Unknown DEX version. Trying anyway...\");\r\n        }\r\n        this.dex_version = version;\r\n        in.order(ByteOrder.LITTLE_ENDIAN);\r\n\r\n        // skip uint checksum\r\n        // and 20 bytes signature\r\n        // and uint file_size\r\n        // and uint header_size 0x70\r\n        skip(in, 4 + 20 + 4 + 4);\r\n\r\n        int endian_tag = in.getInt();\r\n        if (endian_tag != ENDIAN_CONSTANT) {\r","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L144-L180","documentation":"DexFileReader validates the 4-byte magic at the start of the container. A 'dey ' magic means an odex (optimized/odexed) file, which dex2jar does not parse; it throws DexException('Odex unsupported.'). An odex contains a DVM-specific pre-optimized format rather than a portable DEX.","triggerScenarios":"Opening an .odex file (or any stream whose first bytes are 'dey\\n') with DexFileReader or higher-level APIs that delegate to it.","commonSituations":"Trying to decompile system-app odex files pulled from a device /system partition; passing a yanked odex instead of its corresponding dex; old baksmali-style workflows.","solutions":["Obtain the portable classes.dex instead — extract from the APK, or deopt/deodex the odex (e.g. with an oat/dex deoptimizer tool matching the device's Android version)","Check the file magic before parsing: read the first 4 bytes and only pass 'dex\\n' files to DexFileReader","Catch DexException around DexFileReader open/accept to classify the input cleanly"],"exampleFix":"// before\nnew DexFileReader(odexFile);\n// after\nbyte[] magic = readFirstBytes(odexFile, 4);\nif (!Arrays.equals(magic, new byte[]{'d','e','y','\\n'})) {\n    new DexFileReader(odexFile); // proceed only for real dex\n} else {\n    throw new IllegalArgumentException(\"deodex the file first: \" + odexFile);\n}","handlingStrategy":"validation","validationCode":"static boolean isPortableDex(Path p) throws IOException {\n    byte[] m = new byte[4];\n    try (InputStream in = Files.newInputStream(p)) {\n        if (in.read(m) != 4) return false;\n    }\n    return m[0]=='d' && m[1]=='e' && m[2]=='x' && m[3]=='\\n';\n}","typeGuard":null,"tryCatchPattern":"try {\n    DexFileReader reader = new DexFileReader(file);\n} catch (DexException e) {\n    if (e.getMessage().contains(\"Odex\")) {\n        throw new IllegalStateException(\"deodex required: \" + file, e);\n    }\n    throw e;\n}","preventionTips":["Never feed .odex or extracted system files directly to DexFileReader — deodex first","Check the 'dex\\n' / 'dey\\n' magic before opening any container","Extract classes.dex from the APK when available instead of device-optimized artifacts"],"tags":["dex","odex","file-format"],"backgroundTag":"unsupported-file-format","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}