I decompiled an Android APK using Jadx-GUI to view the Java source code. I want to modify the application, but the only way to do that is to make changes to the smali code and repackage the files into an APK via apktool.
I currently have made some changes to the Java code for a particular file. I now want to make the changes to the corresponding smali and then repackage the app. I am confused on how to do this.
Convert .Java file to .Smali file
From this post:
"You can compile the java classes using a normal java compiler, and then use Android's 'dx' utility to convert the compiled .class files to a dex file. And then run baksmali on the dex file to produce the smali files."
I'm not sure what this means. Do I need to just compile the one file I made the changes to? Or do I compile all the files of the project together? Since smali is android assembly, I would imagine that I would need to compile everything together so that registers are allocated properly, etc.
Lastly, if I use a normal java compiler, won't the compiler throw an error when it encounters Android specific imports?
Eg. import android.graphics.drawable
Related
I have developed an app in android studio and test it in my phone. I have formatted my computer and forgot to save my project to somewhere. Now i want to get my source codes back. I get the APK file from my phone (either by using adb and some other tools).
I am using dex2jar and decompile my classes.dex file but it does not show my own Java classes. Is it possible to get them back?
You can decompile it so easily a great tutorial below:
https://futurestud.io/tutorials/how-to-decompile-an-android-app-apk
4 easy steps as below:
1- unzip you apk like you unzip any zip file
2-find classes.dex files
3-convert them to jar file using dexToJar tool
4- open the jar file using JD-Gui application (availbale for windows/ubuntu/mac)
This is usually done by some obfuscator, such as Proguard. This means, among other things, that the class names of your classes will be changed into meaningless names (such as A/B/C) the names will still be different in the fully qualified path of a java class, e.g. you might have multiple ""A" classes in different packages, but other than that you will have those class names multiple times. In most cases it will not harm te functionality of your program, but it will make it harder to reverse-engineer.
If this is your app and you can rebuild it, you can disable ProGuard or a subset of its features, otherwise you will need to reverse engineer it on your own.
I work daily on a large customized version of Android. Our work involves creating new APIs and testing them with our in-house test app. Currently, each person checks out the needed files to make API updates and then requests that I create a new version of the test app that works with their changes. The way I accomplish this, in part, is with a script that grabs their version of the OS files (the ones that declare the APIs) and generates a JAR of these files that is then thrown in the test app's "lib" directory so the test code can reference these new/changed APIs.
I've been able to automate so much of my workflow, but I can't find a way to automate the task of generating the jar from a few .java files that can't be compiled in isolation. I know how to create a jar and manually populate it, but I can't figure out how Eclipse is able to generate .class files for .java input source files that can't be compiled by themselves. The only way that I can currently compile these files is with a multi-hour full OS build, which I don't want to wait on. Also, our build servers don't spit out the individual .class files I would want to zip up in a JAR anyways.
So, does anyone know how to generate a JAR file with .class files compiled from .java src files that appear, by themselves, to be riddled with errors? I currently do this manually with Eclipse's "export project to JAR" ability, but it really irks me that it's the only "non-automate-able" step in my process so far.
I found this, which doesn't handle generation of the .class file(s) from a set of .java files that won't compile alone.
Thanks!
Here is my situation.
I am using a custom programming language thats syntax is based on Java.
In order to compile this *.custom file I use the java classpath to locate the .jar that contains the .class files. This converts the .custom to .java from there I compile down to Java Byte Code and run on JVM. Now I am looking to use this custom language on Android. Is there a way that I can incorporate a .custom file into android and compile into .java and then to Dalvik Byte Code to run? Looking for any suggestions to run .custom on Android
Thanks
The Android dev tools are ultimately operating on Java .class files. If you can compile your code into something that will run on the JVM with the class-library restrictions of Android, you can compile the .class into a .dex. Keep in mind that you'll need to be referring to the Android API in your programs so the Android installer can link them to the Android runtime.
You can either compile to .class and then convert that to .dex using the dx tool. Or you can use DexMaker to go right to .dex from source.
I want to get the Dalvik bytecode for standard Java libraries, I mean, java libraries that are utilized by Android (e.g. java.util.* collections).
I need to get those class files because I want to analyze them, not all of them, but something like java.util.*, java.lang.*, etc.
However, when compiling any Android applications, no class files of those standard libraries would be generated, except for the application code and dependencies libraries.
So I'm wondering how to get the compiled class files (and its corespondent dex files when compiling in Dalvik VM)?
I tried to pull the standard Java libraries in an Android project, like get all the Java source code and add them as application code, OR put the classes.jar (rt.jar) in the libs folder, however, these two ways are not working because the source code or jar file in project will be in conflict with the default compilation environment and so give out dreaded error Conversion to Dalvik format failed with error 1
Any idea how to get what I want?
The sources and the binaries of the system libraries are available as part of the Android SDK. Just look into the install directory platforms/android-{version}/android.jar for the binaries and sources/android-{version} for the sources (if you installed it).
I am trying to generate the source code from apk (which is created by adobe air, which is actually coded in flash)but It generates with no java classes and no images in res folder. The app actually a game app which has a 50 images in it. Can any body suggest me that, how to get the converted flash code into java files and the resource through the apk. I would be obliged if any suggests. Thanks in advance.
umm... you need to disassemble the APK. Did you check inside for .dex or .class files?
If yes, you might be able to use something like DJ Java Decompiler on those .class files. But android uses .DEX files instead of .class and .APK instead of .JARs.