What is a Dex file? A Dex file contains code which is ultimately executed by the Android Runtime. Every APK has a single classes. dex file, which references any classes or methods used within an app.
class files are recompiled by means of dx (Dexer) to Dalvik bytecode, and then they are attached to the . dex file. Dexer is a standard component of the Android SDK tool kit.
The classes. dex file is a Dalvik Executable file that all Android applications must have. This file contains the Java libraries that the application uses. When you deploy an application for Android, RAD Studio includes a classes. dex file that contains the RAD Studio built-in Java libraries.
About the .dex File :
One of the most remarkable features of the Dalvik Virtual Machine
(the workhorse under the Android system) is that it does not use Java bytecode. Instead, a homegrown format called DEX was introduced and not even the bytecode instructions are the same as Java bytecode instructions.
Compiled Android application code file.
Android programs are compiled into .dex
(Dalvik Executable) files, which are in turn zipped into a single .apk
file on the device. .dex
files can be created by automatically translating compiled applications written in the Java programming language.
Dex file format:
1. File Header
2. String Table
3. Class List
4. Field Table
5. Method Table
6. Class Definition Table
7. Field List
8. Method List
9. Code Header
10. Local Variable List
Android has documentation on the Dalvik Executable Format
(.dex files). You can find out more over at the official docs: Dex File Format
.dex
files are similar to java class files, but they were run under the Dalkvik Virtual Machine (DVM) on older Android versions, and compiled at install time on the device to native code with ART on newer Android versions.
You can decompile
.dex using the dexdump
tool which is provided in android-sdk.
There are also some Reverse Engineering Techniques to make a jar file
or java class file
from a .dex
file.
dex
file is a file that is executed on the Dalvik VM.
Dalvik VM includes several features for performance optimization, verification, and monitoring, one of which is Dalvik Executable (DEX).
Java source code is compiled by the Java compiler into .class
files. Then the dx
(dexer) tool, part of the Android SDK processes the .class
files into a file format called DEX
that contains Dalvik byte code. The dx
tool eliminates all the redundant information that is present in the classes. In DEX
all the classes of the application are packed into one file. The following table provides comparison between code sizes for JVM jar files and the files processed by the dex
tool.
The table compares code sizes for system libraries, web browser applications, and a general purpose application (alarm clock app). In all cases dex tool reduced size of the code by more than 50%.
In standard Java environments each class in Java code results in one .class
file. That means, if the Java source code file has one public class and two anonymous classes, let’s say for event handling, then the java compiler will create total three .class
files.
The compilation step is same on the Android platform, thus resulting in multiple .class
files. But after .class
files are generated, the “dx” tool is used to convert all .class
files into a single .dex
, or Dalvik Executable, file. It is the .dex
file that is executed on the Dalvik VM. The .dex
file has been optimized for memory usage and the design is primarily driven by sharing of data.
.dex file
Compiled Android application code file.
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created automatically by Android, by translating the compiled applications written in the Java programming language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With