Code Explosion

Code That Explodes Conventions (In daily life as a programmer I meet problems. This blog where I record them (and more importantly their solutions) so that I can dig them in the future.)

How to decompile android apk to java source code?

Updated Post:

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:

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- . 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

40 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:
    It is much easier.

    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 …..

    • Bazlur Rahman
      November 9, 2012

      You’re welcome :) you can like facebook my page now :D

  12. Abiram
    November 9, 2012

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

    • Bazlur Rahman
      November 9, 2012

      You’re welcome :) you can like my facebook page now :D

  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 results in, and
    are these files part of code or should i delete those files and keep only

  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,


  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-
    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-

  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..

  22. Sonali
    October 10, 2013

    Hi Bazlur Rahman,
    First of all thanks a lot for this great tutorial, such an amazing much needed, so useful keep it up God Bless You
    Using this Tutorial, I am able to get Java, XML files, resources, drawables, manifest etc.
    Actually i am facing some issues in Java code, in short getting many Errors like:
    1. The type of the expression must be an array type but it resolved to Object
    2. Type mismatch: cannot convert from int to LinearLayout
    3. Type mismatch: cannot convert from LinearLayout to int
    4. The method setVisibility(int) in the type View is not applicable for the arguments (LinearLayout)
    5. Type mismatch: cannot convert from int to boolean
    6. – monitorenter cannot be resolved to a variable
    7. – Syntax error, insert “AssignmentOperator Expression” to complete Expression
    8. The label label175 is missing
    9. The local variable localObject may not have been initialized
    Thanks again, i will wait for your reply…

  23. Ashok
    February 14, 2014

    dex2jar version: translator-
    this cmd is deprecated, use the d2j-dex2jar if possible
    Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils
    at com.googlecode.dex2jar.v3.Main.main(
    Caused by: java.lang.ClassNotFoundException:
    at$ Source)
    at$ Source)
    at Method)
    at Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    … 1 more
    what can i do ? plz help me ?

  24. sai manohar boidapu
    February 25, 2014

    I have tried to extract code from .apk file.I didnt get file and in java code i am seeing lot of absolute values instead of .

    how to rectify it ??
    please help…!!

    thanks a lot in advance…!

  25. Synkrone
    March 15, 2014


    I followed every instruction and i get this error.

    Error: Could not find or load main class com.googlecode.dex2jar.v3.Main

    Do you have any idea what I might have done wrong?
    I was thinking the dex2jar.bat file is located in the wrong place.
    But I am not sure as to where I should put it…

  26. Jagdish
    July 18, 2014

    Getting error. Don’t follow this link…

  27. Manjunatha Reddy
    December 1, 2014

    Is there any procedure to extract native libraries from apk file.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s

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

Join 347 other followers


  • SVG Compressed
    My recently published Kindle book, SVG Compressed, has received some great reviews already. 4 reviews with 5 stars. Not a bad start, but this is also my longest book so far, and it is available for only $0.99 on Amazon, so you get a lot for the money!
  • jQuery Compressed - 2nd Edition
    I have updated my Kindle book, jQuery Compressed 2nd edition, to be compatible with jQuery 1.11.0 and 2.1.0 .
  • Java Arrays February 26, 2015
    Everything you have ever wanted to know about Java arrays, including how to declare, instantiate, iterate, copy, fill, sort, search etc. Java arrays.
  • Java Fork and Join February 3, 2015
    This new tutorial explains how to use the ForkJoinPool in Java 7 to use the fork and join recursive work break down technique, for parallizing task execution.
  • jQuery - Creating an Expandable Tree January 26, 2015
    This tutorial explains how to turn a ul element into an expandable tree with jQuery.

my tweets


Get every new post delivered to your Inbox.

Join 347 other followers