Full tutorial to patch APKs on Android using apk-mitm and APKLab. Support for bundle APKs.
adb shell pm list packages
adb shell pm path <package_name>
If the app contains a single APK:
adb pull /data/app/~~SzA2evEyrPV2ucUpwPzYYQ==/some_path==/base.apk base.apk
If it's a bundle APK (multiple APK files):
- Install Split APKs Installer (SAI)
- Backup the app to a
.apks
file - Load the file to your computer
- Extract the
.apks
file (it's an archive!) - Create a copy of the
.apks
file, we will need it later when rebuilding the app
Open base.apk
with APKLab with options:
- Only main classes
- Decompile Java
Inspect the Java code in the java_src
directory, find the function you want to edit.
When found, go to its .smali
file equivalent in the smali
directory, do your edit and save.
Right-click on the apktool.yml
file: APKLab: Rebuild the APK
.
The APK file is generated at dist/base.apk
.
If you are working on a single APK, you can install it to your phone:
adb install dist/base.apk
- Open your copy of the
.apks
file as an archive - Delete the
base.apk
file from the archive - Add your
dist/base.apk
patch APK file to the archive
Using apk-mitm
apk-mitm my_app-edited.apks
╭ apk-mitm v1.2.1
├ apktool v2.6.1
╰ uber-apk-signer v1.2.1
Using temporary directory:
/tmp/apk-mitm-ab640ef99e9eacd6b96f033651301328
✔ Extracting APKs
✔ Patching base APK
✔ Signing APKs
✔ Compressing APKs
Done! Patched file: ./my_app-edited-patched.apks
Use the --certificate
parameter your proxy SSL certificate
apk-mitm --certificate charles_proxy_certificate.pem my_app-edited.apks
- Load the
my_app-edited-patched.apks
file to your phone - Install Split APKs Installer (SAI)
- Install it
Enjoy! 💕