tags:

views:

338

answers:

3

The hard drive on my laptop just crashed and I lost all the source code for an app that I have been working on for the past two months (I know I am an idiot for not backing it up)

All I have is the APK file that is stored in my email from when I sent it to a friend. My question is: Is there any way to extract my source code from this APK file? I realize that is is most likely a shot in the dark... but I am really desperate.

I have read about tools like smali and apktool... could these be of help?

+1  A: 

While you may be able to get an APK decompiler somewhere, you will likely hit one big issue: its not going to return the code you wrote. Its going to return whatever the compiler inlined, with variables given random names, as well as functions given random names. It very well may take significantly more time to try to decompile and restore into the code you had, then it will be to start over.

Sadly, things like this have killed many projects. For the future, I highly recommend learning a Version Control System, like CVS, SVN, git, etc... and how to back it up.

Ryan Gooler
A service like Dropbox will also help.
fiXedd
+1 for dropbox. Best thing ever
Falmarri
+2  A: 

apktool will work. You don't even need to know the keystore to extract the source code (which is a bit scary). The main downside is that the source is presented in Smali format instead of Java. Other files such as the icon and main.xml come through perfectly fine though and it may be worth your time to at least recover those. Ultimately, you will most likely need to re-write your Java code from scratch.

You can find apktool here. Simply just download apktool and the appropriate helper (for Windows, Linux, or Mac OS). I recommend using a tool such as 7-zip to unpack them.

Ryan Berger
+2  A: 

apktool is the best thing you can try. I have saved some xml with it, but honestly I don't know how it will work with the .java code.

I would recommend you to have a code repository even if your are the only coder. I've been using Project Locker for my own projects. It gives you free svn and git repos.

Macarse