There are two ways to decompile an APK and peek into the code. Well if you’re expecting to directly decompile and get your hands on the source code then wake up because that’s not possible yet but you can determine the logic and/or the basic working of an app by the below-mentioned methods though it might be tough to understand at first.

Method 1: Using apktool

1. First of all download, the necessary files mentioned at the end of the post.

2. Extract and place the files apktool.jar and apktool.bat in a folder. In my case its, C:\Users\princ\Desktop\Apktool-Tutorial .

3. Now copy the apk you want to extract to the same folder.

4. Right click on the address bar of the folder and select “Copy address as text”option.

5. Fire up Command Prompt by pressing Win + R > type cmd > Press Enter or by navigating to Start menu and searching for “cmd”.

6. Then in cmd type cd<space>paste the address of the folder copied earlier by just a right click and hit enter.

7. Finally you can now decompile the apk by the following commands- apktool<space>d<space>appname.apk

8. Get back to the folder containg the apktool and stuff and if the apk gets decompiled successfully you will be able to see a folder having same name as the apk.

9. All the resource xml files will be decompiled and present in res folder and the java code of the apk will be decompiled in .smali format in smali folder.

10. You can also modify the .smali files according to your needs and then recompile the files to get the .apk.

11. To recompile the files, the following command is used:- apktool<space>b<space>appdirectoryname

 

Method 2: Using dex2jar and jd-gui

1. First of all download, the necessary files mentioned at the end of the post.
2. Extract and place the files dex-tools and jd-gui in a folder. In my case its, C:\Users\princ\Desktop\Apktool-Tutorial .


3. Now copy the apk you want to extract to the same folder.
4. Right click on the apk and select “Open with” option.


5. Click on “Look for another app on this PC” option.


6. Now browse in C:\Program Files or C:\Program Files (x86) for “WinRAR” folder.

7. Open the folder, select and WinRAR.exe and click open.


8. After it opens, right click on classes.dex file and select “Extract to a specified folder”


9. Then browse to dex-tools folder and click OK.


10. Now navigate to dex-tools folder, right click on the address bar of the folder and select “Copy address as text”option.


11. Fire up Command Prompt by pressing Win + R > type cmd > Press Enter or by navigating to Start menu and searching for “cmd”.


12. Then in cmd type cd<space>paste the address of the folder copied earlier by just a right click and hit enter.


13. Finally you can now convert the classes.dex file to a .jar file by the following commands- d2j-dex2jar<space>classes.dex . A file named classes-dex2jar.jar will be created in dex-tools folder.


14. Open jd-gui.exe and select File > Open File.

15. Browse and select the .jar file and click open.


16. Finally, you can now see the .class files and browse them.

17. In this method, you can only examine the code in .class format but you cannot modify them.

Downloads

Apktool.jar || Apktool.bat (Right Click -> Save Link As) || Dextools || JD-GUI

Apktool || Dextools || JD-GUI    (Mirror Links)

Leave a Reply