Files with extension .dex (Dalvik Executable) is a compiled bytecode that is used in Androidapplications. They contain executable code optimized for the virtual machine Dalvik or ART. If you encounter such a file, most likely you need to either analyze it (for example, for reverse engineering) or extract resources from the APK. But how to do this on the device itself Android, without resorting to a computer?

In this article we will examine 5 working methods opening .dexfiles - from simply viewing the contents to full decompilation into readable code. It is important to understand that working with such files requires caution: incorrect actions can disrupt the operation of applications or even the system. We will also explain why some methods only work on rooted devices, while others are available to everyone.

If you are not a developer, but just want to extract data from an APK (for example, pictures or sounds), standard tools may be enough for you. Advanced tasks such as code modification or malware analysis will require specialized utilities. Let's start with basic methods and gradually move on to complex ones. What is a DEX file and why open it? A file is a file used in applications. When you install an APK, the system extracts one or more

What is a DEX file and why open it?

File .dex - This compiled version of Java code, used in Android-applications. When you install an APK, the system extracts one or more classes.dexfiles from it, which are then executed by the virtual machine. Here are the main reasons why users want to open such files:

  • ๐Ÿ” Security analysis: checking the application for malicious code or vulnerabilities.
  • ๐Ÿ› ๏ธ Application modification: changing the logic of the app (for example, to remove ads or unblock functions).
  • ๐Ÿ“‚ Resource extraction: gaining access to graphics, sounds or configuration files.
  • ๐Ÿ‘จโ€๐Ÿ’ป Development training: studying someone else's code to understand the working mechanisms of Androidapplications.

It is important to note that decompilation .dex to source code does not always give a 100% accurate result. Compilation removes some information (such as variable names), so the reconstructed code may be difficult to read. In addition, some applications use obfuscation (for example, ProGuard or R8), which further complicates the analysis.

โš ๏ธ Attention: Decompiling and modifying other people's applications may violate license agreements copyright laws. Use these methods only for legal purposes, such as analyzing your own projects or open source software.

Method 1: Viewing DEX contents through a file manager

If you just need to see what is inside a file (without decompilation), you can use standard tools .dex-file (without decompilation), you can use standard tools Android. This method is suitable for preliminary analysis and does not require root access.

Steps:

  1. Install a file manager that supports viewing binary files, for example FX File Explorer or Solid Explorer.
  2. Find the file in the device memory (usually it is located in the folder .dex-file in the device memory (usually it is located in the folder /data/app/package_name-1/apk inside the APK file).
  3. Open the file in view mode hex editor (if the manager supports this function).
  4. You will see bytecode in hexadecimal format. For an untrained user, this will be a meaningless set of characters, but experienced developers can recognize signatures and structures.

This method does not allow you to edit the file or convert it into readable code, but it does allow you to verify that the file is not damaged and is indeed .dex. For a deeper analysis, specialized tools will be required.

๐Ÿ’ก

If you need to extract .dex from an APK, simply rename the file .apk to .zip and extract it with an archiver. Inside you will find a folder with classes.dex

Method 2: Decompiling DEX into SMALI code (without ROOT)

For conversion .dex into intermediate low-level code SMALI (assembler for Dalvik) you can use applications directly on Android. This method does not require superuser rights, but provides limited capabilities compared to a PC.

The best tools for this:

  • ๐Ÿ“ฑ APK Editor Pro - allows you to decompile the APK and view smalifiles.
  • ๐Ÿ”ง Dex2jar (via Termux) - converts .dex to .jar, which can then be opened by a decompiler.
  • ๐Ÿ–ฅ๏ธ JADX (there are ported versions for Android) - decompiles directly to Java code.

Usage example APK Editor Pro:

  1. Install the application from Google Play or from the official website.
  2. Select the option Select APK from app and specify the target application.
  3. Click Full Edit and wait for unpacking.
  4. Go to the folder smali โ€”there will be files with the extension .smalithat can be viewed and edited.
โš ๏ธ Warning: Editing smalifiles without knowing the syntax can lead to app crash. Always make a backup copy of the original APK before making changes.

Install APK Editor Pro|Download the original APK|Create a backup|Check the free space (need ~2-3 APK sizes)|Close the target app before editing

-->

Method 3: Complete decompilation into Java code (with ROOT)

To obtain the most readable code you will need decompilation in Java. On Android this can be done using Termux and a set of tools dex2jar + JD-GUI. This method requires root access to access system folders and install additional packages.

Instructions:

  1. Install Termux from F-Droid (version from Google Play is outdated).
  2. Update packages and install dependencies:
    pkg update && pkg upgrade
    

    pkg install wget openjdk-17

  3. Download dex2jar:
    wget https://github.com/pxb1988/dex2jar/releases/download/2.1/dex-tools-2.1.zip
    

    unzip dex-tools-2.1.zip

  4. Convert .dex to .jar:
    cd dex-tools-2.1
    

    d2j-dex2jar.sh /path/to/file/classes.dex -o output.jar

  5. To view .jar use JD-GUI (must be downloaded separately) or JADX.

The result will not be ideal (variable names can be replaced with a, b, c), but the main logic of the code will become clear. To improve readability, you can use deobfuscators, but this requires programming skills.

Tool Requires ROOT? Output format Complexity
APK Editor Pro โŒ No SMALI Low
Termux + dex2jar โœ… Yes Java (JAR) Average
JADX โŒ No Java Low
Ghost Commander โŒ No Hex-view Low

Security analysis|Application modification|Resource extraction|Development training|Other-->

Method 4: Online decompilers (without installing software)

If you do not want to install apps on the device, you can use online services for decompilation. This method is convenient, but has risks:

  • ๐Ÿ”’ Privacy: you upload the file to a third-party server, where it can be analyzed or saved.
  • ๐Ÿšซ Limitations: many services do not support files larger than 10-50 MB.
  • โš ๏ธ Malicious code: Some DEX files may contain viruses that are activated upon download.

Popular online tools:

How to use:

  1. Go to the service website.
  2. Download .dex or .apkfile.
  3. Wait for processing (may take several minutes).
  4. Download or view the result (usually in the form of an archive with .javafiles).
โš ๏ธ Attention: Do not upload files containing Personal data or closed source code to online services. For confidential projects, use only local tools.
What are the dangers of an online decompiler?

Some services may store uploaded files in their database, which allows third parties to access your code. Additionally, if the DEX file contains malicious code, uploading it to the server may result in your IP being blocked or even legal consequences (if the file violates laws).

Method 5: Analyzing DEX via ADB (for developers)

If you have access to Android Debug Bridge (ADB, you can extract and analyze .dex-files directly from the device, without resorting to decompilation. This method is useful for debugging or analyzing running applications.

Basic commands:

  • ๐Ÿ“‹ View a list of installed packages:
    adb shell pm list packages -f
  • ๐Ÿ” Find the path to APK:
    adb shell pm path com.example.app
  • ๐Ÿ“‚ Copy DEX to PC:
    adb pull /data/app/com.example.app-1/base.apk
    

    unzip base.apk classes.dex

  • ๐Ÿ› ๏ธ View information about DEX:
    adb shell dexdumper /data/app/com.example.app-1/base.apk

    (requires ROOT)

For advanced analysis you can use IDA Pro or Ghidra (both support .dexfiles), but these tools require reverse engineering skills. If you just need to extract rows from DEX, you can use the command:

strings classes.dex | grep "searched_string"
โš ๏ธ Attention: Commands dexdumper and access to /data/app/ require root access. Without them, you will only be able to work with files copied to the SD card or to accessible folders.
๐Ÿ’ก

ADB is the most powerful tool for working with DEX, but requires a connection to a PC and knowledge of the command line. For most tasks, Termux or APK Editor will be enough.

Common errors and how to avoid them

When working with .dexfiles, users often encounter problems. Here are the most common errors and ways to solve them:

  • ๐Ÿšซ "The file is damaged" โ€” check the integrity of the DEX using dexcheck:
    adb shell dexcheck classes.dex

    If the file is damaged, try extracting it again from the APK.

  • ๐Ÿ”„ "Can't decompile" โ€”some DEX files protected Obfuscation or ProGuard. Use JADX with the option --deobf.
  • ๐Ÿ“ต "Out of memory" โ€” decompiling large files (more than 50 MB) can require up to 2-4 GB of RAM. Close all background applications.
  • ๐Ÿ”’ "Access denied" โ€”if you are working without ROOT, copy the file to an accessible folder (for example, /sdcard/Download/).

If you have modified smali-files and the application does not start, check:

  • ๐Ÿ“ Syntax โ€”even an extra space in smali can cause an error.
  • ๐Ÿ”„ APK signature โ€”after changes, the file must be signed again:
    jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore mykey.keystore app.apk alias_name
  • ๐Ÿ—ƒ๏ธ Paths to resources โ€”if you changed the file names, update the links in smali.
Is it possible to open a DEX file without ROOT?

Yes, but with restrictions. You will be able to view the smalicode via APK Editor Pro or convert DEX to JAR using Termux, but access to system folders (for example, /data/app/) will be denied. For full-fledged work, it is recommended to use a PC.

Which decompiler gives the most readable code?

JADX usually shows better results compared to dex2jar + JD-GUIas it better restores the class structure. However, no decompiler will return the original variable names if they have been obfuscated.

Is it possible to modify the DEX file and install it back?

Technically yes, but to do this you need to:

  1. Decompile the DEX to smali.
  2. Make changes and compile back to DEX.
  3. Replace the file in the APK and rewrite the signature.

Without ROOT, installing a modified APK on top of the original one will not work - you must first delete the old application.

Is it legal to decompile other people's applications?

Depends on the purpose and jurisdiction. In most countries, decompilation of personal use or security research is allowed, but distribution of modified versions or commercial use other people's code violates copyright. Always check the application license.

Why after decompiling the code unreadable?

This happens due to:

  • Obfuscation (class and method names are replaced with a, b etc.).
  • Compiler optimizations (for example, method inlining).
  • Using closed source libraries.

To improve readability, try deobfuscators like Procyon or CFR.