Decompile APK, modify an activity and recompile to APK

Itay Ganor picture Itay Ganor · Jul 1, 2017 · Viewed 9.6k times · Source

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:

  1. Decompile it with APKtool.
  2. Open it with Android studio.
  3. Change the value you want.
  4. Couldn't recompile it to APK.

  1. Decompile it with APKtool / Open the APK with 7-Zip.
  2. Convert classes.dex to jar using dex2jar.
  3. Open the jar file using luyten or jadx (jd-gui had an "internal error").
  4. 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!

Answer

Suresh picture Suresh · Jul 1, 2017

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