. apk is the executable extension in Android OS, to decode source code(java files) and its respective user interface(xml file) from it. I will show a short demo with pictures to describe it,

I took a simpleswap application’s apk file, and I done this in linux platform with debian(distro)

Part 1 – To get the source file .java of project

1) rename the existing .apk file into .zip format,

FlashLightDemo.apk -> FlashLightDemo.apk.zip

2) Extract it to give folder,with name FlashLightDemo.apk, navigate inside to it and look for classes.dex file

3) Download dex2jar convertor, extract it at safe place, copy the classes.dex into the extracted dex2jar folder. Navigate to the extracted folder using terminal

$ cd dex2jar-x.x.x.x x/

 

$ ./dex2jar.sh classes.dex

As a result you may get classes_dex2jar.jar inside the same extracted folder.

4) Download the java decompiler, else google it you will definitely get java decompiler, extract it and look for jd-gui, double click Image

and navigate to classes_dex2jar.jar, you may get source code with package names, as below

Image

Click on respective Source File and select SAVE SOURCE under File Tag, you can get all source files together in zip format,  but sometimes it becomes hard to unzip it.

Part 2 – To get XML file

1) Copy the .apk file onto new folder

2) Download apktool1.5.2.tar.bz2 and apktool-install-linux-r05-ibot-tar-bz2 put both at same folder

3) Download framework-res.apk file and put in the same folder

4) Extract apktool-install-linux-r05-ibot-tar-bz2 and apktool1.5.2.tar.bz2 

5) Copy  apktool.jar of apktool1.5.2.tar.bz2, .apk file of application and framework-res.apk inside extracted  apktool-install-linux-r05-ibot-tar-bz2 folder.

6) Open new terminal and navigate to extracted apktool-install-linux-r05-ibot-tar-bz2 folder, and type

$ ./apktool if framework-res.apk

It will install the framework.

7) And type,

$ ./apktool d "application".apk

It will decode needed, res/, AndroidManifest.xml and smali/ inside newly generated folder

Hence source file,layout, and Manifest.xml with you and Enjoy..!

Advertisements

2 thoughts on “How to decode Source code from .apk of Android

  1. hey, in part-1 third option you mentioned that open terminal and run terminal to get jar file but it’s not working

    Like

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 )

Google+ photo

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

Connecting to %s