Java – Decompile the APK, modify an activity to recompile the APK

Decompile the APK, modify an activity to recompile the APK… here is a solution to the problem.

Decompile the APK, modify an activity to recompile the APK

I’m trying to do something simple. I have an APK file and I want to change a variable value in an activity and then recompile it back into the APK so I can use it on my android device.

It’s been days since I started using it and I can’t find any solution.

I tried these methods :

  1. Decompile with APKtool.
  2. Open it with Android studio.
  3. Change the value you want.
  4. It cannot be recompiled into an APK.

  1. Decompile it with APKtool/Open the APK using 7-Zip.
  2. Use dex2jar to convert classes.dex to jar.
  3. Open the jar file using luyten or jadx (jd-gui got an “internal error”).
  4. The file cannot be edited.

In another method, I don’t remember how I did it, I was able to get the activity file but couldn’t understand how to recompile it into an APK.

Please let me know if you have any ideas on how to edit classes and activities. I’ve read a lot about SO issues and googled many times, but I can’t find any solutions. Thanks!

Solution

With the Android apk tool, you can only decompile existing APKs. You can’t recompile it. An error will be reported

If you want to convert a dex file to a JAR file

and then convert a JAR file to a dex file, this will not work in most cases.

But there is a solution available ..” DexPatcher”。 I tried this but got stuck due to lack of knowledge… You can try the “Dexpatcher tool” and it will be good. If you have any ideas, please let me know…

Have a nice day

Related Problems and Solutions