Code Explosion

Code that explodes conventions

How to decompile android apk to java source code?

Updated Post: http://codexplo.wordpress.com/2013/03/22/how-to-decompile-android-apk-to-java-source-code-2/

I think it’s very often we want to explore the existing projects source code but again sometime it may not be  available. Personally I love to dig on existing project to know how people write their codes.

Suddenly I thought, if there is any apk to java source decompiler, it would be a nice thing.  You probably know, android runs on dalvik virtual machine, so when we compile android java code, its compile to dex( dalvik executable). So I search a lot to find a way how to convert dex to jar ,and I know already how to decompile jar file to java source code.

At last I found the way out.

Here is the way-

You will need-

  1. Eclipse IDE
  2. Java Runtime (of course)
  3. JD-GUI or JD Eclipse plugin
  4. DexToJar (get them from here: http://code.google.com/p/dex2jar/)

And now follow the steps

Step 1:  Create a java project, name it DexToJava.

Create a java project

Step 2: Create a folder and name it libs. Paste all jars file in the libs folder after extracting dex2jar-0.0.9.8.tar.gz . Go to build path. Add all the jars in the build path.

Step 3: You are almost done.  Get an apk file and paste it in your project. For me it is facebook.apk.

Step 4: right click on project and select run as.  Set main class: com.googlecode.dex2jar.v3.Main

Step 5: Set Argument facebook.apk and now click on apply and run it.

Step 6: after completing the job, you will find on console:

Step 7: now refresh the project, and you will find facebook_dex2jar.jar. And you know already how to get java source from jar. Use JD-GUI.

That all.

I think you enjoy it.

About these ads

33 Comments on “How to decompile android apk to java source code?

  1. Pingback: Latest-Tutorial » Spring 3 Hello World Example » Latest-Tutorial

  2. mike
    May 15, 2012

    Hello. How do you do the step 5? Where do you set the argument to your apk file?

    • Bazlur Rahman
      May 18, 2012

      right click on your project, goto run as, then select run configuration..

      right click>Run As>Run Configuration..
      I hope you will get it now .

  3. Atanas
    May 17, 2012

    Take a look at AndroChef Java Decompiler: http://www.neshkov.com/ac_decompiler.html
    It is much easier.

  4. BANDI SHANKAR
    June 18, 2012

    But nowadays people are obfuscating there code , so after decompiling also it will not help us. Do u have any solution for this.

    • Bazlur Rahman
      June 18, 2012

      decompiling obfuscating code would be difficult. sorry i have no idea right now, if i get the solution, surely i will post the solution here, stay tuned. thanks.

  5. Jeff Fandl
    July 4, 2012

    This is a great start but the instructions are very incomplete. Step 5 was the worst for the argument. What you should do is go to the Argument tab, select File promt and click OK, then apply. Then Run. It will prompt you for the location of the .APK file. Then it will finally create the jar file.

  6. deepak dhiman
    September 4, 2012

    Uuseefull link

  7. thanks
    September 9, 2012

    about step 7. no, i actually don’t know how to get java source from jar. that’s why i read your article. which was helpful, but not straightforward. next time try not to skip with the details. what might seems simple and clear to one, not always the same for the other.
    thanks anyway

  8. Theera
    October 30, 2012

    Hi Bazlur Rahman,
    I ‘ve problem which not clearly in step 5. I ‘ve already seen the picture in step 4.
    But I don’t know that how to set Argument after select Argument tab? Please show me the picture.

    • Bazlur Rahman
      November 1, 2012

      just write facebook.apk on the argument tabs text area, it will work..

  9. toti
    November 4, 2012

    impossible de trouver ou charger la classe principale com.googlecode.dex2jar.v3.Main!!!!!!!!

  10. satheesh
    November 8, 2012

    i have completed .apk to .jar , i want to know how to get java source from jar ……

  11. satheesh
    November 8, 2012

    thank you …..

  12. Abiram
    November 9, 2012

    Thank u. Helped me a lot to Develop a app in One Day :)

  13. satheesh
    November 23, 2012

    how to decompile xml files alone from .apk without using java decompiler….

  14. raj
    December 10, 2012

    please explain how to set the argument in 5 th step……..

  15. mayur
    December 26, 2012

    yes way, nicely worked! but i am getting $ sign in file names. for eg: original HomeForm.java results in HomeForm.java, HomeForm1.java and HomeForm2.java.
    are these files part of code or should i delete those files and keep only HomeForm.java?

  16. Ramesh
    January 10, 2013

    hi it is very usefull

  17. Ramesh
    January 10, 2013

    But one dought … Emulator is Working or not Bluetooth code

  18. Don Fulano
    January 12, 2013

    First, thank you for the tutorial. I disagree about ambiguity in step 5. For a novice eclipse user, it wasn’t that hard. I imagine that your tutorial assumes a certain level of proficiency on the part of the student…

    That said, may I ask for a bit of guidance?

    I followed your steps. I used Windows Explorer to create folder, copy/past .jar files. I told Eclipse to include them and saw them in the project. I set main class to com.googlecode.dex2jar.v3.Main but when I set the argument to my xxxxxxx.apk and clicked run, I received an immediate message: ERROR: com.googlecode.dex2jar.v3.Main could not be found.

    Where am I missing a step? I have the Android SDK installed. Should I create the new project as an Android project rather than a java project?

    Thanks in advance,

    Fulano

  19. Vinay Gupta
    April 11, 2013

    Hey …
    I have message in consol like as following:

    “this cmd is deprecated, use the d2j-dex2jar if possible
    dex2jar version: translator-0.0.9.13
    dex2jar file1.dexORapk file2.dexORapk …”

    I have followed all above step properly. So please help me asap

  20. rachana
    April 11, 2013

    hey m gettin following error:
    do help…
    this cmd is deprecated, use the d2j-dex2jar if possible
    dex2jar file1.dexORapk file2.dexORapk …
    dex2jar version: translator-0.0.9.13

  21. Aleem Quadri (@al33m)
    April 14, 2013

    hi, can you also show how to import the decompiled source code in eclipse..
    every time i import a decompiled apk folder to the eclipse, the src folder in eclipse shows numerous errors..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 291 other followers

RSS Jenkov.com

  • Java Exception Handling - New book published!
    Download this book for free from Amazon until and including march 1st! Exception handling is an aspect of Java development that has not received as much attention as it deserves. If you do not have exception handling under control, you risk that your application or data ends up in an unhealthy state, which can have serious consequences. That is why I wrote t […]
  • HTML4 Compressed - Kindle book published
    In this day and age it should be easy and cheap to learn HTML4, which everyone needs to learn in order to learn HTML5. Therefore I published this Kindle book which explains HTML4. The parts of HTML4 that is not removed in HTML5, that is.
  • jQuery Compressed - Updated
    I have updated the jQuery Compressed book to be compatible with version 1.9.1 of jQuery.
  • Displaying SVG in Browsers
    The SVG tutorial has been updated, showing how to include SVG in HTML pages using the img HTML element, or the SVG element.
  • Maven Tutorial.
    This Maven tutorial explains the core concepts of Maven which are important to understand for new Maven users.

my tweets

Follow

Get every new post delivered to your Inbox.

Join 291 other followers