In order to get an android app onto the Google play market you need to sign you application with a private key. This signing is actually happening each time you debug your app or test it on a real device, the private key and alias are known only to your SDK.
In order to sign a application there are several strategies you should follow.
- Use the same certificate for the life time of you application
- This includes updates to your application. During an update the certificate used to sign the update and the certificate used to sign the old version are compared. If they match, the update is published. If they do not match, the new package is published as a new app. This means that all your end used must install a new app to get the update.
- Ensure that your key has a suitable lifetime on it. In order to publish to Google play your key must has a validity period ending after 22 October 2033
Signing in Release Mode
To create a self signed certificate for your release, you need to use the oracle / Java tool called Keytool. If the java folder is in your PATH variable as JAVA_HOME then you should be fine. Try running Keytool via the terminal / command line, if it runs, your good.
Next is to actually run the keystore command. The blow is an example provided by the android documentation.
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
After running this command , remember what alias you used. Next, the keytool will prompt you for several things.
- Keystore password (keep track of this)
- Firstname and Lastname
- Name of organisational unit (such as Development or Marketing)
- Name of your organisation
- Name of your city / locality
- Name of your state / province
- Two-letter country code
- Key password (This can be different from the keystore password, but doesn’t need to be, keep track of this)
Lastly, the keystore will be generated in whatever directory you in when you ran the command.
Assuming your doing this to then use phonegap build, now sign into your account and add a new certificate to your android builds. This is where you’ll provide the alias, key password and the keystore password.
Once you submit your key, all subsequent builds will be built with key.