Monday, December 9, 2013

How to decompile an Android APK file

I was wondering how easy it is to decompile my Android APK files into source code files. So I did some searching using Google Search and found a few decompilers, some free and some commercial stuff. It seems that the process can be done in two steps: (1) convert the APK file to a JAR file, and (2) convert the JAR file to JAVA files.

The first step can be done using open source program dex2jar from https://code.google.com/p/dex2jar/downloads/list. The second part can be done using a Java decompiler from http://jd-gui.softpedia.com/. The Java decompiler will decompile the JAR file into the Java source code files. Using these two programs, it was very easy to reverse engineer the Android APK file as shown below:
  1. Open up a Command Prompt.
  2. Type in the d2j-dex2jar.bat command (assuming it is in the system path, otherwise you need to type in the whole command path) to convert an apk file e.g. androidgames.apk.

    C:\> d2j-dex2jar.bat androidgames.apk

    The apk file is converted to a jar file androidgames-dex2jar.jar.

    Note: the suffix "-dex2jar.jar" is appended to the file name.
  3. Now run the Java decompiler jd-gui.exe by double clicking the executable from the Windows Explorer.

    The Java Decompiler application appears.

  4. Click File | Open File. Browse and select the jar file created previously.


  5. Click Open.

    The classes and source code files are displayed in the application.


3 comments:

Andrew Rukin said...

There is new alternative to this old apktool->dex2jar route: open-source APK and DEX decompiler called Jadx: https://sourceforge.net/projects/jadx/files/
It has also online version here: http://www.javadecompilers.com/apk/

Andrew Rukin said...

Hi!
Thank you for the article.
I maght also add, that there new alternative to this APKTool->dex2jar->JD-GUI route!

Just try open-source APK and DEX decompiler called Jadx: https://sourceforge.net/projects/jadx/files/
It has also online version here: http://www.javadecompilers.com/apk/

Bapuji Nakka said...

How to protect classes.Dex

Related Posts with Thumbnails