Decompiling and recompiling frameworks.jar in android stock rom - java

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.

Related

Revert minify enabled and proguard effect on decompiled apk

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.

Android Compilation: No rule to make target

I am trying to compile an android kernel from source for an ODROID-XU4 (http://www.hardkernel.com/main/products/prdt_info.php?g_code=G143452239825). I downloaded the source, added a few custom drivers & external programs, and now I am trying to create a git repo with all kernel source & custom source. Before I created the repo, my source compiled and deployed fine. After creating the repo, pushing my source, and then cloning it back to my machine, the source no longer compiles. Running make at top of the new source results in the following error:
Install: out/target/product/odroidxu3/data/nativetest/dalvik-vm-unit-tests/dalvik-vm-unit-tests
make: *** No rule to make target out/target/common/obj/JAVA_LIBRARIES/android_webview_java_intermediates/javalib.jar, needed by out/target/common/obj/JAVA_LIBRARIES/webviewchromium_intermediates/classes-full-debug.jar. Stop.
I believe the problem is with my .gitignore files. I think that pushing to the repo leaves behind some crucial files that are necessary for compilation, but I'm having trouble finding out which files are not included. Any suggestions as to what files might be missing?
For clarification, I have two source trees, one is the original (which compiles successfully) and one which is an exact clone of the original, but is missing files specified by the default .gitignore files.
Also, the android source I downloaded and have been modifying was from here: https://github.com/hardkernel/android.
Any help is appreciated.
Delete external folder in your AOSP root directory and replace it with the original one.

Java class editor like eclipse viewer

I decompiled a Java .jar file, after editing the problem i'm having with it, its not compiling again. So, i had to opt-in to using 7-zip to just bring out the class file and, now i've used 5 different Class Editors, all can't show me the codes like i can understand...
I used CE(Classeditor.sourceforege.net), dirtyjoe, javaeditor(javaeditor.org), Jad and JD-GUi(Seems not to do its work at all)
I imported the .jar file into Eclipse as a Project Reference Library and the most painful thing is i can see all of the class codes, but i can't edit it...It won't edit. But, it can run.
What can i do to Eclipse to be able to make it allow editing the .class files attached to it.
EDIT: I want A Class Editor That Shows in Codes Format, not bytecodes.
I have the source as well in .java format.
This Example is Eclipse Class Viewer(I want same, but not only viewer).
Eclipse Class Viewer Image, I want something similar
It sounds like you want to be able to edit class files directly. The Eclipse class viewer only works because it finds (in your project folder or online) a source code version of the jar that you're viewing. It's not actually looking at the class files and decompiling them, AFAIK. So, if you can view the source in Eclipse, your best bet may be to find the source version of the jar (on your machine or on maven, possibly, if you're using maven), and then edit it and build it yourself according to that project's build instructions. How hard that is depends on the library.
As far as being able to decompile, edit, and recompile, I'm not sure. I know that decompilers are not foolproof, and I've only used them as a last-ditch, read-only tool. It seems like it should work both ways, but I wouldn't be surprised to hear it doesn't.

Getting thousand errors after importing code from an apk

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

Problems importing WAR files in Eclipse?

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.

Categories