Skip to content

Instantly share code, notes, and snippets.

@PuKoren
Last active May 31, 2024 15:18
Show Gist options
  • Save PuKoren/d0ec0c98350c0e92f467 to your computer and use it in GitHub Desktop.
Save PuKoren/d0ec0c98350c0e92f467 to your computer and use it in GitHub Desktop.
Recompile APK + Sign with apktool
# You must first install apktool (https://github.com/iBotPeaches/Apktool) and android SDK
# and decompile apk using it
# apktool d -rf my-app.apk
# then generate a key for sign in:
# keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
rm signed-app.apk
apktool b -f -d com.myapp
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore com.myapp/dist/com.myapp.apk alias_name
zipalign -v 4 com.myapp/dist/com.myapp.apk signed-app.apk
adb -d install -r signed-app.apk
adb shell am start -n com.myapp/com.myApp.MainActivity
adb logcat | grep -E 'filter-logcat1|filter-logcat2|...'
@sikrinick
Copy link

Why there are two apk files?

zipalign does not overwrite input apk with output.

@sikrinick
Copy link

sikrinick commented Dec 3, 2022

Btw, jarsigner won't work for Android 11+, due to Signature Scheme V1 deprecation.

@unixfox
Copy link

unixfox commented Dec 13, 2023

Need to use apksigner sign --ks my-release-key.keystore -v signed-app.apk now instead of jarsigner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment