Skip to main content

Decompiling Android .apk file


Follow the procedure given below, to retrieve source from an apk file.

1.      Start with renaming the extension of file from .apk to .zip (e.g.: rename from filename BuyCokeAndroid.apk to filename BuyCokeAndroid.zip) it automatically converted into zip file and then extract it. If you open extracted file, you will able to see “classes.dex” file.

2.      Convert “classes.dex” to “classes.jar”. To convert into jar file use the tool “dex2jar”. Download on this link http://code.google.com/p/dex2jar/downloads/list  and then extract it in same folder where the classes.dex file is located.

3.      Now, open command prompt and reach to the folder where the classes.dex file is located.
For e.g. c:\Users\v.nadeshan\apk decompile\BuyCodeAndroid>
Windows: - Then type the command “dex2jar classes.dex” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> dex2jar classes.dex and enter
Mac: - Then type the command “sh dex2jar.sh classes.dex” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> dex2jar classes.dex and enter and press enter.
Output: - You get classes.dex.dex2jar file in the same folder.

4.      Now, download java decompiler from http://java.decompiler.free.fr/?q=jdgui and double click on jd-gui.exe and java Decompiler window is displayed. Open classes.dex.dex2jar file in Java Decompiler and then you can see the source files in the jd-gui window. You can save the source files by selecting File>Save All Sources option and you will get the source files as zip.

5.      Download apktool and it dependencies to retrieve correct xml files like layout files and Android-Manifest.xml file. Download apktool from http://code.google.com/p/android-apktool/downloads/detail?name=apktool1.5.2.tar.bz2&can=2&q= and for it dependencies download from http://code.google.com/p/android-apktool/downloads/detail?name=apktool-install-windows-2.2_r01-3.tar.bz2. Extract both zip files and put the content in the same folder where the .apk file is located i.e. BuyCokeAndroid folder.

6.       Download framework-res.apk file and put it in same folder where the .apk file is located i.e. BuyCokeAndroid folder.

7.       Now, open command prompt and Navigate to the directory where your .apk file is located (c:\Users\v.nadeshan\apk decompile\BuyCodeAndroid>)and type the following command

Command 1

Windows: - Then type the command “apktool if framework-res.apk” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> apktool if framework-res.apk and enter
Mac: - Then type the command “sh apktool if framework-res.apk” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> sh apktool if framework-res.apk and enter and press enter.
Output: - you get a file folder in that folder and now you can easily read xml files also.
            
Command 2

Windows: - Then type the command “apktool d “framework-res.apk”” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> apktool d “framework-res.apk” and enter.
Mac: - Then type the command “sh apktool d “framework-res.apk” next to above path. c:\Users\v.nadeshan\apk decompile\ BuyCodeAndroid> sh apktool d “framework-res.apk and enter and press enter.
Output: - you get a file folder in that folder (framework-res) and now you can easily read AndroidManifest files also.

"Happy Testing"

Comments

Popular posts from this blog

Collect console logs for iOS devices

Mostly I work in a windows environment and it is necessary to get console logs for iOS devices to find out the root cause of the issue. We can get iOS app crash log from this path ( C:\Users\AppData\Roaming\Apple Computer\Logs\CrashReporter\MobileDevice\DSS-Iphone 6 ) in windows machine using iTunes. But we need an entire app log to understand what goes wrong in the application. And after some research, I found iTools which allow you to manage iOS devices and also show entire device logs. This tool helps me to do my testing. As per my understanding, this tool will not run without iTunes. iTools was also affected by the latest iTunes update. Now I have found some other tool called 'iOSLogInfo'. Download and run iOSLogInfo to get console log for iOS devices in windows. Requirements:- iOSLogInfo ( Download link - https://www.blackberry.com/blackberrytraining/web/KB_Resources/KB36986_iOSLogInfo_4.3.4.zip    ) iTunes for windows Steps:- Download and save iOSLogInfo ...

Test Android app battery consumption with Battery Historian Tool

Requirement:-  1. Android ADB 2. Download the open source Battery Historian python script from GitHub.       https://github.com/google/battery-historian . 3. Unzip the file to extract the Battery Historian folder. Inside the folder, find the historian.py  file and move it to the Android SDK platform-tools folder.            Steps:- 1.  Connect your mobile device to the computer. 2.  On your computer, open a terminal window. 3.  Change to the directory where you have saved historian.py.        D:\Android\sdk\platform-tools> 4.  Shut down your running adb server.       >adb kill-server 5.  Restart your adb server.          D:\Android\sdk\platform-tools> adb start-server 6.  Check for connected devices.          D:\Android\sdk\platform-tools> adb devices 7.  Reset...

MIND MAP - A ULTIMATE THINKING TOOL FOR SOFTWARE TESTING

I am the only tester in my team testing all Android, iOS and web projects. Traditional way to prepare test documentations like test strategy, Test Plan and test cases takes  more time. It's not possible for me to keep track all the features I have tested and need to test when I am having a multiple project's release on the same day . Still doing conventional approach of testing, i.e. maintain and execute test cases and mark them as "Pass/Fail". Getting limited time for testing because of maintaining all these test documents. In some releases I have missed lots of scenarios/functionalities to test due to less time for testing and this makes me unhappy after every release. After a long search I came to know the blog about "Mobile Testing Mind Map" in adventuresinqa.com.  A mind map technique helped me to design rapid, clear, higher coverage and more efficient test cases using mind map technique. Then, I started using this technique for all the projects. ...