Quick reference for decompiling, patching, and reinstalling Android APKs with split configurations.
- Android SDK Build Tools installed
- Java JDK installed
- apktool installed
- ADB connected to device
# List installed packages
adb shell pm list packages | grep <package_name>
# Pull base APK
adb pull /data/app/~~<hash>~~/<package_name>-<hash>==/base.apk
# Pull split APK (if exists)
adb pull /data/app/~~<hash>~~/<package_name>-<hash>==/split_config.arm64_v8a.apk
apktool d base.apk -o base
Edit files in the base/
directory (smali files, resources, etc.)
A. Enable Network Security Config (for HTTPS interception)
- Create network security config file:
# Create the xml directory if it doesn't exist
New-Item -ItemType Directory -Force -Path "base/res/xml"
# Create network_security_config.xml
@"
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system"/>
<certificates src="user"/>
</trust-anchors>
</base-config>
</network-security-config>
"@ | Out-File -FilePath "base/res/xml/network_security_config.xml" -Encoding UTF8
- Modify AndroidManifest.xml:
<!-- Add these attributes to the <application> tag -->
<application
android:networkSecurityConfig="@xml/network_security_config"
android:debuggable="true"
... >
B. Enable Debugging
In base/AndroidManifest.xml
, add android:debuggable="true"
to the <application>
tag.
apktool b base -o base-patched.apk
& "D:\Android\android-sdk\build-tools\34.0.0\zipalign.bat" -v 4 "base-patched.apk" "base-patched-aligned.apk"
& "C:\Program Files\Java\jdk-17\bin\keytool.exe" -genkey -v -keystore "debug.keystore" -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 -storepass android -keypass android -dname "CN=Android Debug,O=Android,C=US"
# Sign the patched base APK
& "D:\Android\android-sdk\build-tools\34.0.0\apksigner.bat" sign --ks "debug.keystore" --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android "base-patched-aligned.apk"
# Sign the split APK
& "D:\Android\android-sdk\build-tools\34.0.0\apksigner.bat" sign --ks "debug.keystore" --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android "split_config.arm64_v8a.apk"
adb uninstall <package_name>
adb install-multiple "base-patched-aligned.apk" "split_config.arm64_v8a.apk"
Create base/res/xml/network_security_config.xml
:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">10.0.2.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system"/>
<certificates src="user"/>
</trust-anchors>
</base-config>
</network-security-config>
Add to <application>
tag in base/AndroidManifest.xml
:
<application
android:networkSecurityConfig="@xml/network_security_config"
android:debuggable="true"
android:allowBackup="true"
android:usesCleartextTraffic="true"
... >
Error: Targeting R+ (version 30 and above) requires the resources.arsc...
Solution: Use zipalign
before signing (Step 5)
Error: INSTALL_PARSE_FAILED_NO_CERTIFICATES
Solution: Use apksigner
instead of jarsigner
for modern APKs
Error: Failed to extract native libraries
Solution: Ensure split APK is properly signed and uninstall original app first
project-folder/
├── base.apk # Original base APK
├── split_config.arm64_v8a.apk # Original split APK
├── base/ # Decompiled source
├── base-patched.apk # Rebuilt APK
├── base-patched-aligned.apk # Aligned & signed APK (final)
└── debug.keystore # Debug signing key
# Full workflow
apktool d base.apk -o base
# [make modifications]
apktool b base -o base-patched.apk
zipalign -v 4 base-patched.apk base-patched-aligned.apk
apksigner sign --ks debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android base-patched-aligned.apk
apksigner sign --ks debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android --key-pass pass:android split_config.arm64_v8a.apk
adb uninstall <package_name>
adb install-multiple base-patched-aligned.apk split_config.arm64_v8a.apk
Automatic Script to do it on windows, check config and paths though before running