1

Unfortunately I deleted my Android source code. Tried to get jar using dex2jar and baksmali and used jd-gui to get java source files using my .apk file. Yes I got the files but the problem I have is, in more places in the java file, the code is in byte format. Need to get that to readable format to get myself to move forward.

asked Apr 13, 2013 at 3:38

2 Answers 2

2

Decompiling is not a perfect science, and you rarely get back the exact Java code you typed.

When you compile your code, a bunch of optimizations are done on it, which make decompiling more difficult if you're aiming to get the original code.

At best, you'll get a lot of decently decompiled code, along with some byte code. You should be able to figure out what Java code to substitue for that byte code based on where in the program it is, seeing as you wrote the original code.

For most simple apps, it is easier to rewrite from scratch than it is to decompile and try to fix that decompiled code.

tl;dr: Don't forget to backup your code. Ever.

answered Apr 13, 2013 at 3:44
Sign up to request clarification or add additional context in comments.

6 Comments

But my most important operations and business logics were in byte format. You mean there is no way to get that back ? Should I go from scratch ?
@Joseph There are byte tables available online, and if you really spent time on it you might be able to manually convert from byte code to corresponding Java, but it would take ages. I would suggest that you start from scratch.
A lot of optimizations? Javac doesn't really do optimization. The Android toolchain might though.
@Antimony The Android tool chain does a fair bit of optimization, as they want to be able to run the code on even low end devices (at least uptil Android 2.2). There's an SO answer listing them out by a Google Employee, but I can't seem to find it atm.
@Raghunandan Obfuscation just makes decompiled code harder to read. It does not change the actual functioning and logic.
|
0

Generally if your goal is to get readable source back, then something like JD-Gui is your best bet. But for cases where it fails, you could try Krakatau, a decompiler I've written.

Krakatau is designed to be able to decompile classfiles, even if they're obfuscated or not compiled from Java. However, the result is less readable then something like JD-Gui because it doesn't take advantage of the patterns left by the Java compiler. It's not perfect, but I think it's definitely worth a try.

P.S. Krakatau only supports JVM bytecode. You'll need a way to convert it from Android back into Java bytecode before you can decompile it.

answered Apr 13, 2013 at 4:05

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.