What is .apk file?
APK file is nothing but Android Package File(APK). APK is the file format used to distribute and install application software and middleware on Google's Android operating system.
Apk Files are Zip file formatted packages based on the JAR file format, with .apk extension. Apk files contains all program resources and code i.e it contains .dex files, resources, assets, certificates, and manifest file.
How to get source (java files) from .apk file?
As we now know that apk file is just a zip file containing all program resource file, we can now get java code from apk files with ease. Following are steps to get java code from apk files.
Step 1:Renaming .apk file
Step 2:Getting java files from apk
Step 3:Getting xml files from apk
APK file is nothing but Android Package File(APK). APK is the file format used to distribute and install application software and middleware on Google's Android operating system.
Apk Files are Zip file formatted packages based on the JAR file format, with .apk extension. Apk files contains all program resources and code i.e it contains .dex files, resources, assets, certificates, and manifest file.
How to get source (java files) from .apk file?
As we now know that apk file is just a zip file containing all program resource file, we can now get java code from apk files with ease. Following are steps to get java code from apk files.
Step 1:Renaming .apk file
- Rename the .apk file with the extension .zip (for example let the file be "demofile.apk" then after renaming it becomes "demofile.apk.zip")
Step 2:Getting java files from apk
- Now extract the renamed zip file in specific folder, for example let that folder be "demofolder".
- Now Download dex2jar from the link for windows and extract that zip file in folder "demofolder".
- Now open command prompt and go to the folder created in previous step and type the command "dex2jar classes.dex" and press enter.This will generate "classes.dex.dex2jar" file in the same folder.
- Now Download java decompiler from the link and extract it and start(double click) jd-gui.exe
- From jd-gui window browse the generated "classes.dex.dex2jar" file in demofolder, this will give all the class files by src name.
- Now from the File menu select "save all sources" this will generate a zip file named "classes_dex2jar.src.zip" consisting of all packages and java files.
- Extract that zip file (classes_dex2jar.src.zip) and you will get all java files of the application.
Step 3:Getting xml files from apk
- Download apktool and apktool install from the link and extract both files and place it in the same folder (for example "demoxmlfolder").
- Place the .apk file in same folder (i.e demoxmlfolder)
- Now open command prompt and goto the directory where apktool is stored (here "demoxmlfolder") and type the command "apktool if framework-res.apk"
- Above command should result in "Framework installed ..."
- Now in command prompt type the command "apktool d filename.apk" (where filename is name of apk file)
- This will generate a folder of name filename in current directory (here demoxmlfolder) where all xml files would be stored in res\layout folder.
Android Application Package File(APK). all apk files are suitable to be fixed in Android Tablet PC and Smartphone, aren't they?
ReplyDeleteWow that was unusual. I just wrote an very long comment but after I clicked
ReplyDeletesubmit my comment didn't appear. Grrrr... well I'm not
writing all that over again. Anyway, just wanted to say great blog!
My site :: how to delete cookies from computer
I get all java files that's great but I can't able to get XMLs because I can't understand what you are saying by executing the command "apktool if framework-res.apk"
ReplyDeleteIt's not working or else I have done some mistakes.
So please, could you explain me again???
Error you are receiving is because you are not having apktool.jar file which you can download from link "apktool install" from above post, as there was same link for "apktool" and "apktool install" you were not able to download apktool.jar from "apktool install" link, it has been rectified, now just download it and try it out
Deleteyou must download apktool and framework-res.apk..just search it on google
DeleteI get everything OK. But how to make/import it into Eclipse as a project?? or can we do this??
ReplyDeleteYou can import files in eclipse using "import...existing Android code into workspace " option from File Menu or by simply doing copy-paste from windows into project explorer
Deletei am getting 'Java'not recognized as an internal or external command error, why?
ReplyDeleteIt means either Java is not installed, or is not in your path. Ensure that Java is installed and Java executable is in your system's path.
DeleteI am getting an error "Dext2jar classes.dex" is an invalind command (In the command prompt
ReplyDeletelooks like you are doing typing mistake, it is not Dext2jar classes.dex but it is dex2jar classes.dex
DeleteActually I did a Typo Error while writing to you..I am getting the "Invalid Command" error when i type dex2jar classes.dex.
Deleteseems like you have missed to download one of the specified files, retry it.
DeleteThanks for sharing this.
ReplyDeleteI did everything you said,i extracted the java files and the xml files;i cannot import the java files in eclipse;how can i do this?please answer because i have a project at school thursday.thank you:)
ReplyDeleteyou need to explicitly copy these java files and paste into your project from eclipse or other IDE.
DeleteYou can also directly put these java files in source directory of your project.
Great........ Thanks...
ReplyDeleteExcellent Men. This is something Real Good. Worked absolutely Fine. Thanks.
ReplyDeletewaw it is too.....good.....excellent
ReplyDeleteit'greate....
ReplyDeleteGood post! All worked for me! but I have all these files how to put them back into a project!!
ReplyDeleteThanks buddy for sharing it.....
ReplyDeleteGreat worked for me thanks :)
ReplyDeleteGreat!! Its working 100%.. Thanks man..
ReplyDeleteWorked ..!! lovely. thanks brother for sharing that stuff.
ReplyDeleteThis has saved me and my App a lot .. Thanks
ReplyDeleteVery nice guid to the new people like me. thanks man.
ReplyDeletewoooooooooooooooooooooooooooooooooooooooooooooooooow
ReplyDeleteGreat share sir!!! thank you very much. For the xml part I have used in the command prompt "apktool" instead of "apktool if framework-res.apk" and worked nice. THANKS
ReplyDeleteYou saved me time! thanks
ReplyDelete+1
ReplyDelete+1
ReplyDeleteGreat Blog Helps me a lot..
ReplyDeleteSmart-wentech.com
thanku i really needed xml file :)
ReplyDeleteThank Uuuuuuuuuuuuuuuuuuuuuuuuuu :) :) :)
ReplyDelete1000000000000000000000000000000000000000000000000 Likes
ReplyDeleteproblem is solved....
ReplyDeleteWoooooooow manh it is worked for me
ReplyDeleteand i recovered lost project from .apk file
after facing several error but it is useful
thanks for posting..
JUST WOOOW
ReplyDelete