- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to decompile Android DEX (VM bytecode) files into corresponding Java source code?
Android platform uses a virtual machine which is known as Dalvik VM which is used to execute the android application code. Dalvik VM executes the code in a format called DEX (Dalvik Executable). DEX files are the compiled version of Android application code written in Java. DEX files are a form of bytecode and can be decompiled into the corresponding Java source code.When we build a project in android studio to generate the APK. The compiler will firstly convert the code to dex and then this generated dex is then converted to the APK. This APK can be installed on the mobile device.
Decompiling is a process in which DEX files are converted back to the Java Source code. The first step of decompiling DEX files is to convert these DEX files into JAR files which is a Java Archive file. There are various tools which can be used for generating this JAR file. This JAR file is easily readable and it contains the resources such as java and other files in which the code for the android application has been written.
Decompiling is generally used to get the source code of any android application from the applications JAR file. This process can be used for the debugging of the application, reverse engineering and understanding the inner logic of the application.
In this article we will take a look at various methods which are used for Decompiling the DEX files into their corresponding Java Source Code which are as follows.
The dex2jar is a programming tool which is designed to convert Android DEX files into corresponding Java Source Code. It is also use to extract the contents of the APK file of the application to view the source code of an android application. For using the dex2jar tool we have to first download and install this tool on our local machine and then we have to run the below command from the command line.
In the file name we have to specify the name for our dex file.
The above command will generate the Java class file for each class in that dex file. This generated class files can then be decompiled through Java Decompiler using tools such as JD-GUI.
APK Tool is a reverse engineering tool which is used to get the JAVA source code from any android application. It is used to decode the resources to nearly original form and rebuild them after making some modifications. APK tool is used to decompile DEX files by first extracting classes.dex file from the APK file of the application. Once it is extracted the classes.dex file can be decompiled using the below command.
apktool d fileName.dexThe above command will generate a folder which will contain the decompiled source code. This source code can be viewed and edited in any text or code editor.
JAD is a Java Decompiler which is also used to decompile DEX files into Java Source code. It is a command line tool which is used to generate Java class files from the DEX file. For using JAD we have to first download and install it on our local machine and then we can use the below command to generate and decompile the DEX file.
Above command will generate a Java class file (.class) which can be opened in any of the text/code editors to view the decompiled source code.
JEB is a Java Decompiler for android applications which is developed by PNF Software. It is a commercial, cross platform tool which is used to reverse engineer APK packages and decompile the DEX files into Java source code. JEB has a built-in decompiler that can be used to decompile DEX files in a single step. It also has a powerful graphical user interface for navigating and editing the decompiled source code.
Decompiling DEX files into their corresponding Java source code can be a useful tool for debugging, reverse engineering, or for understanding the inner workings of an Android application. In this article, we discussed the various methods of decompiling DEX files, including using dex2jar, Apktool, JAD, and JEB. Each of these tools has its own advantages and disadvantages, so it is important to choose the right one for your needs.
Kickstart Your Career
Get certified by completing the courseGet Started