One of the key feature of Android OS is - it's open source availability. APK file is the final build for every Android application. If you lose your application source code, you can retain your code with APK file by performing reverse engineering.
APK file:APK file is an android package file i.e.; it is an executable file on android operating system.
I've recently developed one small android application called "Callduration". But unfortunately, I lost the code when my system was crashed. I only have the .apk file of my application which is a build file. I've found a way for extracting the source code from apk file.
In order to regain source code from apk file, you need below tools on your machine. Please download them and follow the procedure explained below
android-apktool: this tool extracts all the contents of the apk file i.e.; xml files, resource files etc. You can download this tool from http://code.google.com/p/android-apktool/
dex2jar: this tool allows us to extract a jar (Java archive) file from the .dex file. You can get this tool from http://code.google.com/p/dex2jar/
java decompiler: since you get the class files in the above step from a jar file, you will now need a decompiler to extract the .class file code to readable java source code. You can use any decompiler, but I've used jd-gui which is the best in the market. You can download this @ http://java.decompiler.free.fr/?q=jdgui
Once you download above three tools, you have to follow below steps in order to extract the apk file content
1. Get the apk file for which you would like to see the code. You can get the apk file by taking a backup of your application with "Atro file manager" application.
2. Place the apk file under your current working folder
3. Extract xml configuration files and resource files of apk with apktool. You can run below command to do the same.
apktool d <apk file name>
Note: apktool is an executable file for apktool software that you've downloaded above.
4. Extract classes.dex file from the apk file with jar command of java software
jar xvf <apk file name> classes.dex
5. Extract jar file from classes.dex file generated in the step 4. You've can extract a jar from dex file by using dex2jar software.
After running this command, you will have a jar file of all the class files for your code.
6. Now you've all the .class files of the apk as part of the jar file that is generated in step 5. You can get the source code by using decompiler.
Download the source code...! and enjoy programming....!!