Tuesday 19 February 2013

How To Extract Java source code and XML Layout from the APK file

We can extract the code from apk file these are some of the tools that will help you to extract the source code and xml layout file from the apk files.

There are three tools you will need: apktool, dex2jar, and jd-gui (or any other java decompiler, 

JD Gui happens to be the best one I’ve found so far). You can download them from the 

following URLs:
 

http://code.google.com/p/dex2jar/

http://code.google.com/p/android-apktool/

http://java.decompiler.free.fr/?q=jdgui

Make sure you follow the installation instructions for APKTool. Windows users will have to 

download two files to get it working.

Once you have these downloaded and installed, the next thing you will need is an APK.

Now, that you have everything you will need to do the following:
 

1) Extract the APK using APKTool. Run: apktool d <apk>
 

2) Extract the classes.dex file found in the APK file. Run: jar xvf <apk> classes.dex
 

3) Extract the classes from classes.dex file. Run: dex2jar classes.dex
 

4) Extract the classes.dex.dex2jar.jar. Run: jar xvf classes.dex.dex2jar.jar

You now have the raw data available to you. You can use JD-Gui to peruse the extracted 

classes 

and even save the source down as Java. All of the layouts, manifest, strings, images, and assets 

are also available to you in the appropriate folders.