pxb1988/dex2jar · error · DexException
Endian_tag unsupported
Error message
Endian_tag unsupported
What it means
After the magic check, DexFileReader reads the endian_tag field from the DEX header and requires it to equal ENDIAN_CONSTANT (0x12345678, little-endian). This DexException is thrown when the file declares any other endianness (e.g. REVERSE_ENDIAN_CONSTANT 0x78563412, big-endian dex), which the reader cannot decode. The file is structurally a dex but byte-ordered in a way this library does not support.
Solutions
- Rebuild/re-export the dex with standard little-endian tooling (dx/d8) so endian_tag = 0x12345678
- Hexdump the header and verify offset 0x28 (8 magic + 4 checksum + 20 signature + 4 file_size + 4 header_size) contains 78 56 34 12
- Re-obtain the file if the header region appears corrupted
- If you truly have a big-endian dex, byte-swap it or use a reader that supports REVERSE_ENDIAN_CONSTANT
Example fix
// before (hexdump at endian_tag offset) // 12 34 56 78 -> ok; 78 56 34 12 -> throws // after: rebuild with d8 // d8 --output . classes/*.class # produces little-endian classes.dex
Defensive patterns
Strategy: validation
Validate before calling
static boolean hasStandardEndian(byte[] dex) {
if (dex == null || dex.length < 8 + 4 + 20 + 4 + 4 + 4) return false;
int off = 8 + 4 + 20 + 4 + 4; // magic + checksum + signature + file_size + header_size
int tag = (dex[off] & 0xFF) | (dex[off+1] & 0xFF) << 8
| (dex[off+2] & 0xFF) << 16 | (dex[off+3] & 0xFF) << 24;
return tag == 0x12345678;
} Try / catch
try {
new DexFileReader(file);
} catch (DexException e) {
if (e.getMessage().contains("Endian_tag")) {
throw new UnsupportedOperationException("Big-endian DEX not supported: " + file, e);
}
throw e;
} Prevention
- Build dex with standard little-endian tools (d8/dx)
- Check endian_tag (0x12345678) at header offset 0x28 before parsing
- Treat REVERSE_ENDIAN_CONSTANT (0x78563412) files as unsupported and reconvert them
- Verify dex checksum/signature to catch header corruption early
When it happens
Trigger: Opening a big-endian DEX (endian_tag 0x78563412) produced by tools targeting big-endian environments, or a file whose header is misaligned/corrupted so the 4 bytes read as an unexpected endian tag.
Common situations: DEX files from unusual toolchains or converted archives; header corruption from a bad transfer; hand-crafted dex for research that uses the reverse endian tag.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Odex unsupported.
- Magic unsupported.
- The source file is not a .dex or .zip file
- the src file not a .dex or zip file
- Encountered RESTART_LOCAL on new v
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/bf2faa98e9456784.
Report an issue: GitHub.
Appendix: source
Thrown at dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java:181
} else {
throw new DexException("Magic unsupported.");
}
int version = in.getInt() >> 8;
if (version < DEX_035 || version > DEX_040) {
System.err.println("Unknown DEX version. Trying anyway...");
}
this.dex_version = version;
in.order(ByteOrder.LITTLE_ENDIAN);
// skip uint checksum
// and 20 bytes signature
// and uint file_size
// and uint header_size 0x70
skip(in, 4 + 20 + 4 + 4);
int endian_tag = in.getInt();
if (endian_tag != ENDIAN_CONSTANT) {
throw new DexException("Endian_tag unsupported");
}
// skip uint link_size
// and uint link_off
skip(in, 4 + 4);
int map_off = in.getInt();
string_ids_size = in.getInt();
int string_ids_off = in.getInt();
type_ids_size = in.getInt();
int type_ids_off = in.getInt();
proto_ids_size = in.getInt();
int proto_ids_off = in.getInt();
field_ids_size = in.getInt();
int field_ids_off = in.getInt();
method_ids_size = in.getInt();
int method_ids_off = in.getInt();
View on GitHub (pinned to b5bda4fb49)