What is the DEX file format?
A .dex file is a Dalvik Executable - a compiled bytecode container designed to run in the Android system environment. It holds compiled code ready to be executed on Android, and was originally interpreted by the Dalvik virtual machine. Since Android 5.0 (Lollipop), the modern ART (Android Runtime) compiles .dex bytecode ahead-of-time rather than interpreting it, but the format remains the standard Android executable format.
DEX files in APK packages
.dex files are commonly found inside APK packages, which are used for installing new software on Android. Historically each APK contained a single classes.dex file storing all classes and methods used by the application. Larger apps now use multidex - splitting code across classes.dex, classes2.dex, classes3.dex and so on - to exceed the 65,536-method limit imposed by a single file.
Generating and inspecting DEX files
A .dex file may be generated automatically as part of the Android build process, or manually. The modern toolchain uses the d8 compiler (part of Android SDK build-tools) to translate Java or Kotlin bytecode into .dex format. Each file opens with the magic signature dex\n followed by a 3-digit format version number (such as 035, 037, 038, or 039) and a null byte. During installation, ART further compiles .dex into native code, producing .odex or .vdex files stored on-device.
Security & safety
RISK: MEDIUMA .dex itself doesn't run on your PC, so simply having one is low-risk. The real context is Android malware analysis: malicious apps hide their logic in DEX (sometimes loaded dynamically at runtime), so a .dex you extracted from an untrusted APK may contain harmful code. Only inspect such files in a safe environment (decompiler/sandbox), never by installing the parent APK. Be wary of sketchy "dex to exe / dex opener" download sites - they don't do anything legitimate and often bundle adware.
Format details
in a nutshellPrograms that open DEX files
Technical details
deep spec| VM architecture | Register-based (unlike the stack-based JVM; each DEX instruction explicitly names register operands, reducing total instruction count) |
| Magic bytes | 8 bytes at file offset 0: ASCII "dex", newline (0x0A), 3-digit format version (e.g. 035, 037, 038, 039), null byte (0x00) |
| Format versions | 035 (Android 2.2), 037 (Android 7.0), 038 (Android 8.0), 039 (Android 9+); version digits are embedded in the magic header |
| Method index limit | 65,536 methods per .dex file (16-bit method reference index); apps exceeding this split code across classes2.dex, classes3.dex, etc. |
| Integrity fields | Header contains an Adler-32 checksum and a 20-byte SHA-1 signature that together cover the remainder of the file |
| String pool | All string literals are stored once in a shared, deduplicated string pool; bytecode references strings by integer index |
| Byte order | Little-endian by default; the header embeds the endianness constant 0x12345678 to allow detection of reversed byte order |
| Source languages | Java and Kotlin (and any JVM-targeting language); the d8 compiler converts .class bytecode or .jar archives to DEX |
| Build-time compiler | d8 (Android SDK build-tools 28.0.1+) replaced the legacy dx tool; takes JVM .class files or .jar archives as input |
| ART ahead-of-time compilation | At install time, ART's dex2oat converts .dex to native machine code, storing results as .odex / .oat files in /data/dalvik-cache |
| MIME type | application/octet-stream (no dedicated registered MIME type exists for the DEX format) |
| Execution history | Interpreted by Dalvik VM with JIT (Android 1.0-4.4); ahead-of-time + profile-guided JIT compiled by ART (Android 5.0+) |
| Disassembly and decompilation | baksmali disassembles .dex to Smali assembly; jadx and similar tools decompile .dex back to readable Java source code |
| Location inside APK | Stored uncompressed inside the APK ZIP archive; primary entry is always named classes.dex, with classes2.dex onward for multidex apps |
| Released | 2008 (Android 1.0; Dalvik VM, executed by ART since Android 5.0) |
| Open standard | Yes · royalty-free |
| Specification | source.android.com |
DEX conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about DEX files.