apktool
Description
A tool for reverse engineering Android APK files. It can decompile APKs into their constituent resources and smali code, and recompile (rebuild) modified APKs back into installable packages.
Usage 1: Decompile an APK
Decompiles the APK file into a folder containing smali files, resources, and the AndroidManifest.xml.
Command:
apktool d example.apk
Or using the jar directly:
apktool.jar d example.apk
Usage 2: Recompile (Build) a Modified APK
After modifying smali code or resources, rebuild the APK from the decompiled folder. The rebuilt APK will be placed in the dist folder inside the app directory.
Command:
apktool.jar b myapp
Usage 3: Sign the Rebuilt APK
After rebuilding, the APK must be signed before it can be installed. First generate a keystore, then sign the APK with it.
Generate a Keystore:
"C:\Program Files\Java\jdk-21\bin\keytool.exe" -genkey -keystore keystorehere -validity 1000 -alias yaqoob -keyalg rsa
Sign the APK:
"C:\Program Files\Java\jdk-21\bin\jarsigner.exe" -keystore keystorehere -verbose myapp\dist\myapp.apk yaqoob
Verify the Signature:
"C:\Program Files\Java\jdk-21\bin\jarsigner.exe" -verify -verbose -certs app.apk
Notes
- After decompilation, smali files can be found at
smali>com>example>name>myapplication>mainactivity.smaliand the assembly code can be modified there. - Smali files are assembled (bytecode-level) representations of the Android Dalvik code.
- The rebuilt APK in the
distfolder must be signed before installation on a device.