Learn how to decompile an APK file or DEX in Windows using the jadx tool.


Android application package (APK) is the package file format used to distribute and install application software onto Google's Android operating system. There are a lot of reasons why you would like to decompile an APK, to learn how an application works, to increase the security and complexity of your code, to steal source code from applications ... i mean, to analyze it ... and others.

To decompile an APK file, in this article we are going to use jadx, the command line and GUI tool for produce Java source code from Android Dex and Apk files.

Requirements

  • You need obviously Java installed on your machine.

Disclaimer

In no case shall we (Our Code World) or the developer of this application be liable for direct, indirect, special or other consequential damages resulting from the use of this application or from the application packages (APKs) decompiled with it. Use it at your own risk.

1. Download the jadx binaries

To get started with the decompilation of an APK file with jadx, you will need the binaries of this application that you can download through different sources namely Github and SourceForge:

Github releases

This application is public and licensed under the Apache 2.0 License. The source code is available on Github and the binaries are available to download in the releases window here. Download always the latest version:

Github Releases Jadx Github

With SourceForge

You can download the zip with the binaries of jadx from SourceForge here. Download always the latest version:

Download jadx sourceforge

The download of the binaries from any of the previous sources, should be a zip file.

2. Extract zip content

Extract the content of the downloaded zip files into a folder of your preference, the content of the zip will be something like:

jadx binaries content

Of our interest is the bin folder that contains the bat files that allow us to use jadx either with the command line or the graphic user interface (GUI):

JADX executables windows

Important

Execute the bat files with administrator rights, otherwise in some PCs jadx won't even start.

3. Using jadx to decompile an APK

You can use jadx from the command line or from an user graphical interface:

With GUI

jadx is generally used with a graphical user interface, start the jadx-gui.bat file (inside the jadx-folder/bin folder) with administrator rights. As first you will get a window that allows you to choose the APK file that you want to decompile:

Jadx open apk file

Once you've selected the file, jadx will decompile it and will provide an explorer IDE-style (tree style view) in the left side of the application that list all the Java packages and files of the APK. In this example we are going to use the APK of Our Code Editor Premium, whose native code is based in Cordova and the app itself with Javascript (the source code is inside Resources/assets/www):

APK decompiled with JADX

Pretty cool isn't ? You can save all the code within a folder if you click in the top menu, File and Save all.

With the command line

You can use jadx as a command line utility. Open a new command prompt with administrator rights and switch to the bin directory of jadx using the cd command e.g:

cd C:\Users\sdkca\Desktop\jadx\bin

Located in the bin directory where the jadx file is, you can execute the commands, for example to extract the code from an APK, you can use the following command:

REM the command has the following structure
REM jadx -d [path-output-folder] [path-apk-or-dex-file]
jadx -d C:\Users\sdkca\Desktop\source-code C:\Users\sdkca\Desktop\test-apks\ourcodeeditor-premium.apk

The execution of the previous command should extract all the source code in the source-code folder in the desktop (note that the folder should already exist).

Happy decompilation !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors