make android app debuggable with apktool

24年 12月 26日 Thursday
280 words
2 minutes

this post assume that you've installed app that want to be debug.

please use f-droid or other platform instead of pull it directly from your android devices if you encounter error INSTALL_FAILED_MISSING_SPLIT

the step in general:

  1. find the android application package name and its path
  2. pull it to the linux machine
  3. decompile it
  4. update android manifest
  5. rebuild it
  6. reinstall it

Find the APK name

text
adb shell pm list packages | grep <your-filter>
adb shell pm path <package-name>

pull it to your linux machine

text
adb pull <path-base.apk>

decompile it

text
apktool d ./base.apk -o ./disassembly

update android manifest

locate application tag and add this attribute:

text
android:debuggable="true"

optionally, you may also want to rename the package name, edit renameManifestPackage on apktool.yml

if you want to check the package name after renamed:

text
aapt dump badging ./mod.apk | grep package

rebuild it

text
apktool b ./disassembly -o mod.apk
zipalign -p -f -v 4 mod.apk aligned_mod.apk
keytool -genkey -v -keystore debug,keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Lorem, OU=Lorem Department, O=Ipsum Corporation, L=Anytown, ST=CA, C=US"
apksigner sign --ks debug.keystore --ks-pass pass:android --out final_mod.apk aligned_mod.apk

reinstall it

text
adb install -t ./final_mod.apk

note

you could also use this way to patch apk in general, although some application might have some level of protection to prevent you from patch it.

things to keep in mind when you modify or rename the package name:

  • remove line DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
  • adjust attribute of android:authorities with new package name

references:

Title:make android app debuggable with apktool

Author:ReYuki

Link:https://www.reyuki.site/posts/make-android-app-debuggable [copy]

Last updated:


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. You are free to share and adapt it, as long as you give appropriate credit, don’t use it for commercial purposes, and distribute your contributions under the same license. Provided under license CC BY-NC-SA 4.0