From APK to readable java source code in 3 easy steps

Android applications are packed inside a APK file, which is just a ZIP file containing among other things a compact Dalvik Executable (.dex) file.
First step is to extract the “classes.dex” file from the APK:

$ unzip program.apk classes.dex
Archive:  program.apk
  inflating: classes.dex

Now, we use the tool dex2jar to convert the classes.dex file to Java .class files:

$ bash dex2jar/ ./classes.dex
2 [main] INFO - dex2jar ./classes.dex -> ./classes.dex.dex2jar.jar

From here we obtain the file “classes.dex.dex2jar.jar”, now we can use the java decompiler JD-GUI to extract the source code:

$ ./jd-gui classes.dex.dex2jar.jar

Now just go to “File -> Save all sources” and it will generate the zip file “” containing all the decompiled Java source code :)

This entry was posted in android, linux, security and tagged , , , , , , , , , . Bookmark the permalink.

25 Responses to From APK to readable java source code in 3 easy steps

  1. pof says:

    To exctract the original “AndroidManifest.xml” from the APK you can use axml2xml or AXMLPrinter.

    There is also the ‘aapt’ tool in the SDK which allows to read the manifest from any APK:
    $ aapt d xmltree program.apk AndroidManifest.xml

  2. 0xroot says:

    Also you can use jad (Java Decompiler), for transform .class files into .jad and work with any editor or “understand” application from “sci tools” lab for a better code comprehension.


  3. Nandagopal T says:

    Hi, Great Stuff. I got it working, but can anybody suggest a way . how i can able to get the XML files.(Layouting files).

    Thank you

  4. Eduardo says:

    unzip program.apk classes.dex creates no output. What is the problem?

  5. Ramesh says:

    When i extract the apk file as you mentioned i got some of unwanted codes and also the original code was slightly modified. How can i resolve this

    • pof says:

      probably the classes are obfuscated with proguard, as it comes enabled by default on newer versions of the SDK, that’s why you see differences between the original code and the decompiled one.

      To make your reversing life easier, you can use programs like sci tools understand as pointed earlier by 0xroot.

      • syed says:

        Sir, After the de-compilation there is some problem in code… like most of the arguments hav changed into numbers…. So can u pls tell me how to decompile such that there is no such problem….

  6. pankaj says:

    Hi to all,
    I have tried accordingly what u said but i am not getting exact same java file. Is any one getting exact same java file. I used apktool to extract it but got smali file. But got xml file which is correct one but java file is in smali format. I used dex2jar to convert it into jar. And from jar i got the java file but it is not in proper way. There was so many changes. That means i can’t do if i have big project. Is any one can help to how to get java file from apk.

  7. Kamalraj says:

    Once you downloaded your APK file , You need to do the following steps to get a editable java code/document.

    1 -> Convert your apk file to zip (while start your download don’t go with “save” option , just go with “save as” and mention your extension as .zip) by doing like this you may avoid APKTOOL…

    2 -> Extract the zip file , there you can find somefilename.dex. so now we need to convert dex -> .class

    3 -> To do that, you need “dex2jar”(you can download it from , after extracted, in command prompt you have to mention like, [D:\dex2jar-0.09>dex2jar somefile.dex] (Keep in mind that your somefilename.dex must be inside the same folder where you have keep your dex2jar.)

    4 -> Download jad from and extract it. Once extracted you can see two files like “jad.exe” and “Readme.txt” (sometimes “jad.txt” may there instead of “jad.exe”, so just rename its extension as.exe to run)

    5 -> Finally, in command prompt you have to mention like [D:\jad>jad -sjava yourfilename.class] it will parse your class file into editable java document.


  8. marius says:

    WHEN JAVA DECOMPILER IS MAKING THE ZIP ARHIVE, THE APPLICATION CRUSHES…”jd-gui.exe has encountered a problem and needs to close. We are sorry for the inconvenience.”ANY IDEAS?

  9. AndroChef successfully decompiles obfuscated Java 6 and Java 7 .class and .jar files. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source.

  10. Srikanth says:

    For my project requirement i need to get the Andorid version installed on device(mobile) and also the apk version of perticular application installed on the device. Please help.

    Thanks in advance.

  11. palkia says:

    when i open the dex2jar.. the command prompt pop-out but it gones fast…

  12. ajay kumar says:

    Hello Sir,
    i did all what you said but when i run command – bash dex2jar/ ./classes.dex i got ->
    ‘bash’ is not recognized as internal or external command, operable program or batch file. what should i do?

  13. Adhamsheriff says:


    I want to see XML files and datas in apk file.
    it shows data as some decode type.

    Please guide me

    Thanks in advance.

  14. Surag says:

    How to combine source code retrieved from apk.. Plz help me out

  15. wicioszek says:

    How to return to .dex file after editing .java source code?

    Help please

  16. vyshu says:

    sir,after the completion of all the steps where can i will see the xml code

  17. Sriram Viswanathan says:

    Thank you! It works like a charm!

Leave a Reply to Srikanth Cancel reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>