Thursday, July 15, 2010

Android Debug Key Expired? So Did Your Debug Maps API Key!

As an Android developer, you've probably run into an expired debug key by now. If you use the Maps API, you'll inevitably run across the other issue: your maps key is tied to your debug certificate and it also stops working. This happened to me because of a lengthy break from use the Maps API. My old code had a Maps API key in it tied to an equally old debug key. Naturally, using the new debug key meant this didn't work at all.

Now, if you've followed our advice and created a certificate that won't expire for a long, long time, then you can create a debug maps key that will work with it for a long, long time.

It's all pretty simple:

First, create your new debug.keystore file, using all the mandatory values:
keytool -genkey -keypass android -keystore debug.keystore -alias androiddebugkey -storepass android -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
Next, get the certificate fingerprint for use in generating the Maps API key:
keytool -list -keystore debug.keystore -storepass android
Like so:

Command results for keytool


Finally, use that to generate your new Maps API Key. The results will look like this:

After generating new Maps API Key


If your debug.keystore file is now stored in a non-standard location, don't forget to update your build tools. In Eclipse preferences, this is the screen that needs to change:
Edit the path to your debug.keystore file

No comments: