Skip to content

Instantly share code, notes, and snippets.

@lucas-tulio
Last active November 13, 2015 21:36
Show Gist options
  • Save lucas-tulio/ee4fc390e1b2d1ce4737 to your computer and use it in GitHub Desktop.
Save lucas-tulio/ee4fc390e1b2d1ce4737 to your computer and use it in GitHub Desktop.
Android apk build commands. Because I keep forgetting them.
# Create a debug keystore. When it asks for a password, enter "android"
# For a production keystore, change the filename (from "debug.keystore" to something else), the alias (from "androiddebugkey" to something else) and enter a different password
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000
# Jarsigner
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore debug.keystore YourApp.apk androiddebugkey
# Zipalign
# If you get: `zipalign: command not found`, install Android SDK Build Tools 20+. If you can't do that, add the `zipalign` dir to your path. It should be `<sdk-home>/build-tools/<android-version>/`
zipalign -v 4 YourApp.apk YourApp-aligned.apk
# (optional) Shows the SHA1 fingerprint
keytool -exportcert -alias androiddebugkey -keystore debug.keystore -list -v
# (optional) Unsign an apk so you're able to sign it again with a different key
# Use it if you get this error:
# jarsigner: unable to sign jar: java.util.zip.ZipException: invalid entry compressed size (expected 17109 but got 17468 bytes)
zip -d foo.apk META-INF/\*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment