Sign apk package files for publishing in the Android market with keytool and jarsigner on Ubuntu

Once you’ve completed your package with Eclipse and you want to publish it to the android market, google requires that you sign it.  For this step you need two tools.  Keytool and jarsigner can be obtained through JDK.

Open up terminal and install jdk:

sudo apt-get install sun-java6-jdk

Use keytool to make yourself a new key:

keytool -genkey -v -keystore mykeystore.keystore -alias aliasname -keyalg RSA -validity 10000

genkey – generate the key
v – verbose mode
keystore – select name of keystore
alias – creates an alias for the key
keyalg – specifies the encryption algorithm used to generate the key. Ex: RSA, DSA
validity – when should the key expire in days? (google requires like a 50 year expiry)

The keytool will walk you through the process of choosing a password and name.  Once the key is made, you need to sign the apk with jarsigner using this key:

jarsigner -verbose -keystore mykeystore.keystore programfile.apk aliasname

keystore – keystore containing your private key
verbose – verbose mode

You will be prompted for your password. You are ready to go.

2 Responses to “Sign apk package files for publishing in the Android market with keytool and jarsigner on Ubuntu”

  1. […] Sign apk package files for publishing in the Android market with … […]

  2. Any idea why I am getting this?

    Error generating final archive: Keystore was tampered with, or password was incorrect

Leave a comment