Sunday, 11 January 2015

A script to safely manage your Android keystore

Just a quick one for you peeps tonight.
So I screwed up and lost the signing key for my latest app. It's not too bad because it was still in beta, not released to the public. I was sure that I took enough precautions, apparently not. I really don't want this to happen again. The only dangerous part is when you are creating new keys, so I wrote a script!  (addkey.sh)

Get it here

This script works in conjunction with ~/.gradle/gradle.properties, which you should use :)  You won't find much use in this script if you don't use gradle.properties.

How to use

First you configure the script by editing it.  Simply fill in the required information at the top of the script. You can also read the usage.

Then when you run the script (no parameters are needed) it will prompt you for a name and password for a new key. 

That's it. The script takes over. 

What the script does

It gets the keystore's location and password from your gradle.properties file, creates the key as required for Android, and then marks the keystore as read-only so you can't screw it up! :D

It then even makes a backup of your keystore.

And then the script presents you with the information you will need for your gradle.build.

I hope that this helps you out!