I was going through the Stack Overflow question decompiling DEX into Java sourcecode. I was successfully able to decompile the apk file, and I made some changes in the Java code.
I converted them successfully to smali files so that apktool can repack the app. But it gave me undefined kind of errors. I used a Hello, World! example for time being.
Is it possible? Or did I go somewhere wrong? Is there any alternate method is possible for it?
Using dex2jar and a decompiler will produce something vaguely resembling Java source code. Don't expect the result to be compilable, or to actually match the original logic.
Related
I have my project in .jar file.
But i lost the source code of it.
How to get source code from .jar file.
First of all I would like to tell you that if your project is big and complex, you are in trouble. Generated source code via external tools(no matter whatever the tool is) is never same as the real code. Code like comments, constants, inner classes, etc gets messy.
For simpler code and projects you can use -
Java Decompiler (JD-GUI) http://jd.benow.ca/
DJ Java Decompiler http://www.neshkov.com/dj.html
But always know this that its not what was written originally in the source code.
You must decompile your code. You can use Java decompiler http://jd.benow.ca/
Are there ways to decompile obfuscated dex/jar files into Java source code? I have an APK with no classes.dex file within it, but I have the odex file. I've tried using oat2dex and dex2jar to get the dex/jar files, and then used a few decompilers to get the Java source, but I'm either getting errors on some parts, or really hard to read code since it's obfuscated.
Here's what I've tried
JD-GUI (first I've tried that completed decompilation, but with multiple errors)
Fernflower (couldn't complete)
Procyon (pretty good, but with some errors)
CFR (better, but with some errors)
Jadx (best, with least errors, but code is still obfuscated and hard to read, with multiple classes/methods with the same random names)
What can I do to get more readable code?
There isn't any magical tool that will refactor all your obfuscated code into something meaningful and "clean". Obfuscated code is obfuscated: deal with it.
You can however save the obfuscated source code, create a project with your prefered ide (that support refactor) and manually analize functions and variables and refactor them to something meaninful. This require a lot of time, but eventually you will obtain an almost clean source code.
I have a jar file that contains a class file that I need to change a host name in. Simple change if I can get the code decompiled correctly.
When I tried extracting and decompiling with jd gui then recompiling with javac, I get compilation errors because I believe the decompiler didn't read the code correctly.
Next I tried to open the .class file in notepad++ and just change the host name amidst all the symbols and other things, then rejar, and that didn't work either.
I know this is similar to a lot of questions on here, but I can't seem to find my answer.
I deleted a Java project from my hard disk in an attempt to do some refactoring with Eclipse. Luckily I found a recent version of an Executable Jar File and decrompressed it into a bunch of .class files.
I've read some 'decompiling' threads on SO and tried showmycode.com, but I was hoping for more. Isn't it possible to convert .class files into the .java files that made them, comments included - nothing changed? Or find the in the .jar file? What are my best options if not? Other answers on the topic seem outdated. Do I need to download software?
You will not be able to get your comments back, they are lost when you go from .java to .class. As to how to do it any "Java Decompiler" can do it, your code will not be exactly what you wrote, however the code you get back will be functionally the same as what you originally wrote.
JD is a decompiler I have used before and have been happy with its output.
Okay, so my programming teacher sent me an app that I should look at and modify. I downloaded the APK file, and turned it into a source code following these instructions: how to extract code of apk file.
I have the java (src) files, the resources files, and the XML files. I have the Manifest file too.
I imported them successfully on eclipse, but now it has like 2000 errors.
I really don't know what to do. The apk works fine on my phone.
Why is it doing this?
If anyone needs the apk, I'll upload it.
If someone can be so generous to convert it into a working eclipse workspace for me, I'll be more than grateful.
You can never get the exact source code from the .apk file. The .apk file is generated from the compiled classes which doesnt have all information like actual variable names, actual method names. so you cannot retrieve back 100% original source code.
Basically everything will be obfuscated. so when obfuscated, multiple classes may have same name.
eg: two classes may have name 'a'. Hence the Errors in Eclipse.
As far I know re-compiling apk file will not give you exact results except the images and xml resources. Some free tools available that cannot provide 100% accurate code. here's a tutorial you can check How To Retrieve The Source Code From A Compiled Android .Apk