Convert .apk file to .jar using dex2jar

Hey everyone!

Today, Android is an open source software stack for a wide range of mobile devices. Developers can easily obtain the source code from the Android Open Source Project and create their own applications. On the other hand, we can also reverse engineer the executable .apk file of an Android application and obtain the source code.

One of the ways of obtaining the underlying source code is by using the dex2jar library. Dex2jar is a lightweight API designed to read the Dalvik Executable (.dex/.odex) format.

The following steps are used to de-compile the apk!

Step 1: Obtain .apk file

You first need to obtain the .apk file of the application that you wish to decompile. For this purpose, third party applications like App Backup and Restore can be used. Rename the .apk file to a .zip file. Unzip the file to get the contents inside.

Step 2: Decompile .dex to .jar

Once the file is unzipped, one needs to decompile the classes.dex file. The dex file is the Dalvik executable file. The dex2jar tool is used to decode the .dex file to a .jar file as follows!

[On Windows-7]

C:\softwares\dex2jar> dex2jar.bat classes.dex

Step 3: View source code

Finally, you need to open the decoded .jar file using a decompiler of your choice. I would recommend downloading JD-GUI from over here.

output_1

Reference: Decompiling an Android apk file

Karan Balkar About Karan Balkar
self proclaimed extraterrestrial fandroid, computer engineer, amateur gamer and die hard punk rock fan!

11 thoughts on “Convert .apk file to .jar using dex2jar

  1. I got the error using this command..

    ‘java’ is not recognized as an internal or external command,
    operable program or batch file.

    Pl help me how to fix it.

  2. d2j-dex2jar classes.dex

    I got the error using this command..

    d2j-dex2jar is not recognized as an internal or external command,
    operable program or batch file.

    Pl help me how to fix it.

  3. when i type the command as dex2jar.bar classes.dex
    I got this error:

    d2j-dex2jar is not recognized as an internal or external command,
    operable program or batch file.

Leave a Reply

Your email address will not be published. Required fields are marked *