My laptop crashed and i lost my android project ive been working on for the past 6 month. I still have the debug version on my phone. Is there a way i can get the code from that?
-
this seems to be a duplicate of the following question: https://stackoverflow.com/questions/3593420/is-there-a-way-to-get-the-source-code-from-an-apk-file – ashupp Apr 16 '18 at 18:54
-
No his case is regarding an email.. i have it on my phone – Rise of Tech 4K Apr 16 '18 at 18:55
-
Why... why would you go 6 months with a single copy of the code not being backed up to any kind of version control system? Github and many alternatives are literally free... Even if you could retrieve the APK, you would need to decompile it, which will leave you with unintelligible source, with non of your original formatting, variable names, or comments. – Matt Clark Apr 16 '18 at 19:37
-
I do have a backup but its old and o made a lot of changes since – Rise of Tech 4K Apr 16 '18 at 19:50
2 Answers
Oh ok - sorry i misunderstood the question in the first place. For the installed apk there could be a solution in this question: Does Android keep the .apk files? if so where?

- 126
- 1
- 9
Your best bet would be to download the APK from the device using "adb shell pm path [package-name]" to see where the APK is installed, then "adb pull [path]" to download the file on your disk.
Then use a program such as dex2jar to get the class files, and another Java decompiler to get something as close to the source code.
Getting back the XML resources is a bit more tricky. All I can think of is running "aapt dump xmltree [your-app.apk] [path-of-xml]" to get a dump of what your XML resource looks like, but you'd still have to build XML from that manually.
Hopefully you didn't have native code (.so files), otherwise you're probably screwed.

- 15,865
- 4
- 36
- 50
-
do i need a linux distro to run the adb commands? Because with windows it says Error: unknown list type 'ServiceMarket_com.example.appname.apk' – Rise of Tech 4K Apr 17 '18 at 21:39
-