Disassemble an App using ADB and Apktool

This guide will walk you through the process of extracting an APK from an Android Virtual Device using ADB and Apktool.

  1. Pull an Existing App from an Android Device via ADB:

    Use the following command to list packages on the device:

  2. Make Changes and Reassemble the App:

    Make a change in the application files as desired. Then, reassemble the APK using Apktool.

adb shell pm list packages -f

2. Pull the Desired AppOnce you identify the location of the APK ((e.g., /product/app/Chrome/Chrome.apk), use the adb pull command to pull the app.

adb pull [location of the apk]

3. Download and Install ApktoolDownload and install Apktool by following the instructions on Apktool's official website, or use a virtual machine with the tool already installed. 4. Extract and Decompile the APK using ApktoolUse the following command to extract the APK:

apktool d [name.apk]

5. Explore the Disassembled Content:After extraction, explore the different folders and contents in the disassembled APK. 6. Make changes to the files and build / assemble the files with Apktool Go to the application folder with the extracted contents., Make a change to for example:

  • res/values/strings.xml -> Change some visible text in the application

  • AndroidManifest.xml -> Add permission or do a simple change like true -> false

  • MainActivity,smali -> Change the smali code. For example only a string value

7. Build the modified app with apktool

 apktool b .

After above command from the extracted APK folder there should be a new APK file created in the /dist folder. 8. Create a certificate / keystore to sign the modified APK

keytool -genkey -V -keystore key.keystore -alias APKtool -keyalg RSA -keysize 2048 -validity 10000

Pick a simple password like 123456, and use this again in the next step.9. Sign the modified APK with the created certificate using jarsigner (part of Java Development Kit). If you are on a Linux based VM you can install JDK via: sudo apt install default-jdk. Execute the following command from the dist folder:1

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore key.keystore [name].apk APKtool

10. Install the modified app to the device via adb installCOPY

adb install -r [name.apk]

Last updated