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
Related
I have developed an application before and Now I can't find my application source code.
I want to make some changes to my application.
Now I just have my keystore(jks file) which I have use it to sign my application before.
I use online Apk Decompiler to decompile my application but It does not give my desired result.
I need it to edit my codes and give it to the customer but It gives me code preview like below with Incomprehensible class and method names.
My decompiled APK folders directory
My Code Preview
I know that this problem is for setting minify enabled to true for release mode in gradle .
Is there any way to revert decompiled code to understandable code or revert it with keystore or decompile application apk file with understandable source code?
I really need to decompile this apk and do some changes on it .
Specially application source files.
Any help will be appreciated :)
Seems to me you're trying to do some reverse engineering.
That's one of the points of proguard, to make this more difficult.
If you are the developer, see if you saved the mappings.txt file when you did the build. It's will show to what the obfuscated names refer to. Otherwise, no, there is no way to know what the names were before obfuscation without that file.
I'm trying to do something simple. I have an APK file, I want to change a certain variable value in a certain activity, and then recompile it back to APK so I can use it on my android device.
It's been days since I started with it and I can't find any solution for it.
I tried these approaches:
Decompile it with APKtool.
Open it with Android studio.
Change the value you want.
Couldn't recompile it to APK.
Decompile it with APKtool / Open the APK with 7-Zip.
Convert classes.dex to jar using dex2jar.
Open the jar file using luyten or jadx (jd-gui had an "internal error").
Couldn't edit the files.
On a different approach I can't remember how I did it, I was able to get to the activity files, but couldn't understand how to recompile it to APK again.
Please, if you have any idea of how do edit the classes and the activity, let me know. I have read lots of SO questions and google it so many times but I couldn't find any solution for it. Thanks!
Using Android apk tool you can able to decompile the existing APK only. You can't recompile it. It will throw error
If you are going to convert dex file to JAR file and JAR file to dex file that also won't work most of the times.
But one solution is available.. "DexPatcher". I tried this one but got stuck in between do to lack of knowledge... You can try "Dexpatcher tool" it will be good. If u got any idea please let me know..
Have a good day
I suggest you to use APK Studio. You can decompile/recompile apk using it. However, you cannot edit the source in Java. It decompiles in language called smali. If you need to just change a value, I guess this tool can solve your problem.
Use apk-editor.
Apk-editor is app in android
That decompile and recompile apk
apkeditor
I came across a situation where i have to put some debug logs inside some code methods of PackageInstaller.java in my stock ROM.
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/content/pm/PackageInstaller.java
I found that file is deodexed in classes.dex file inside frameworks.java of system folder in the ROM folder. I came across that decompilation will give me the java files (not completely 100% accuracy in code content). So I expects= that these incomplete code base will make blocking in my stock ROM functionality.
So i thought of grabbing a seperate module from this will give me a 100% code base.
https://github.com/android/platform_frameworks_base
So the question is how can I make this git repo to build a new frameworks.jar file?
Compile the repo into a jar file, using usual compilation methods in terminal (CLI).
Or you could even try the docs part in the repo link. The HTML files in the docs folder will surely help you execute the repo.
Hi I am new to Android and I have an apk file from which I extracted the source code.
My problem is that now I need to open all the java and xml files in eclipse as a new Android project for editing.
Right now I am only able to view the java class but not able to run it i.e; I cannot put it in a project I have created. When I try to read the xml files it shows some garbage values.
Thank you for your help in advance.
An .apk files is package that contains the compiled code, not source code. No java files live in there, just the android .class equivalent -- the classes.dex file. There is no way to get the original source (.java files) from the .apk.
Kindly refer this blog post, GT's Blog also this StackOverflow Question decompiling DEX into Java sourcecode
You can try to decompile some of the .class files but I never tried to do it for the XML files. I found a discussion in XDA Developers Blog which may help you. How to decompile/recompile binary XML from .apk file?
I was unfortunately forced to result to uploading a WAR file as my backup for a web application I am working on.
Luckily I have the most recent WAR file available. I am using Eclipse IDE and am using the Web Tools plugin for all the J2EE work that I am doing with the Dynamic Web Application Project.
When I imported my WAR file, and ran it on a local server, everything works fine. The problem I a ran into is that in the Java Resources/src folder that all my packages and .java files were now only consists of all the same packages, but they are empty.
I checked to see if I could find the files and I found the .class files in an "Imported files" folder that is not accessible in the Eclipse Project Explorer. I believe that I need to do some type of build or something so that my .java files are available for me, but unfortunately this is one area where I lack.
One thing I would also like to know is, one way or the other, am I able to obtain the .java source code files if I have access to the .class files?
Also, I would like to configure this environment as it was before where my Java Resources:src folder contaiend the packages and .java files.
One thing I would also like to know is, one way or the other, am I able to obtain the .java source code files if I have access to the .class files?
The short answer is No. There is no way to regenerate original source files from bytecode files.
If you were really, really desperate you could try to use a Java bytecode decompiler on your bytecode files, but the result will be be nothing like your original source code.
All comments and javadocs will be gone.
All original code layout will be gone.
Original local variable and parameter names may be gone, depending on your original compiler switches.
Constant expressions may have been pre-evaluated, and loops, string concatenations and other constructs may have been transformed unrecognizably.
Depending on the maturity of the decompiler, the Java code might not be semantically equivalent to the original code, and might not even be compilable.
I hope you haven't spent too long developing this application because the best answer may be to start again.