Decompile APK, modify an activity and recompile to APK - java

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

Related

How to read the signature into ByteArray from an external APK file

I was trying to crack an apk file and learn its coding philosophy. Here is a part of its source code, which is decompiled from the apk file:
For some reason I need the value of this encodeToString. And I wonder is there a way to get the Byte[] format of the signature from this apk file? Or the raw value is better.
I've try some tools like jarsigner from How do I verify that an Android apk is signed with a release certificate?, to print all the signs out. But I'm not sure if there is any different from the original methods.
Thanks.
Ok this is a silly question. Just copy the package name of the target app and replace it into getPackageName() and everything's fine.

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.

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

How do I use APV PDF Viewer

So I want to view PDFs in my app and I've come across APV PDF, but I just can't understand the instructions on how to use it
http://code.google.com/p/apv/wiki/Building
Why isn't it a jar library to download?
Why do I have to compile some .so files, why can't I download them?
I browsed the source and there is a demo application here:
http://code.google.com/p/apv/source/browse/#hg%2Fpdfview
I copied that into eclipse as an Android project and it compiles but I get an error when I run and select a PDF in the compiled app
java.lang.UnsatisfiedLinkError: parseFile
I understand this has something to do with what I've asked above, so hopefully I'll get some answers.
This probably has something to do with the NDK which I have no experience with.
My mind has been expanded!
1) You can't have a Jar as this is C code, so it is going to run in the NDK therefore the equivalent is a .so file.
2) I don't know why they don't let you just download an .so file (as well as having the source), but it seems this project is just a starter project i.e. you are expected to take the source and modify it. Therefore if you just had a .so file you could not do this. Each time you change the source code in /jni/pdfview2 you have to rerun the script build-native.sh and that will recreate your library (.so) files for you!
I was getting the UnsatisfiedLinkError as the .so library I was using was built against a different version of the code than that which the Java file was trying to reference. Therefore my link was un-satisfied!
Hazar!

How to convert .apk files to java

How to convert .apk files to java in android.
The extension Google uses for Android Applications (APK) may seem a bit complicated at first, but it really isn’t. In fact, an .apk is nothing else than a .zip file disguised as an .apk. That’s dumbing it down, but you get it. Essentially, if one wanted to see what’s inside an app, they would just change the extension of application-name.apk to application-name.zip, unzip it. And there you have it: The contents of the .apk! We aren’t done yet, read more after the break.
Here is where it gets tricky. Inside the folder where you unzipped the contents of the application, you’ll find a file named classes.dex. That’s the most important file of the whole application, containing all the java files, but it’s encrypted! No worries, that can easily be solved. You’ll need two things:
Dex2Jar from http://code.google.com/p/dex2jar/
A regular Java decompiler, such as JD from http://java.decompiler.free.fr
Copy classes.dex to the folder where you unzipped Dex2Jar, and run from the command line: “dex2jar.bat classes.dex”
This will produce a file, strangely named something like: “classes.dex.dex2jar.jar” If you have WinRAR installed, you can just unpack the files. If you don’t, install it.
Now go ahead and adjust it to your liking!
its easy just follow the below 4 steps :
1) Unzip your .apk to the folder and get the classes.dex file.
2)Place this classes.dex file inside dex2jar(you should download this) and execute ./dex2jar.sh classes.dex in the terminal.
3)It will create classes.dex.dex2jar.jar,place it inside jd-gui(you should download this).
4)Execute ./jd-gui classes.dex.dex2jar.jar---will generate the .java files.
You can't just convert a jar to an apk. It has to be compiled for android. Android's java library doesn't have all the swing stuff that's in normal java, so the app most likely would have to be re-written to work on android
Pretty sure MIDlets (MIDP jars) don't use Swing or awt. They have a separate user interface api under javax.microedition.lcdui (http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/lcdui/package-summary.html)
As for converting MIDP programs to runnable APKs, there is certainly a way. Technically it isn't a conversion but the use of a wrapper around the unconverted MIDlet. This is the approach that Opera Mini for Android uses. More info:
http://edugoing.com/qna/index.php?qa=unanswered&start=40

Categories