Pugetworks
Seattle Software Developers

blog-archive

Pugetworks Blog Archive!

An interesting Android mapping Gotcha

If you are deploying google maps in an Android application, here is a tip that will save you some head scratching. Make sure you generate an API key for both your signing certificate and your development machine. If you don't then when you deploy to an emmulator your maps will work, but when you do your production deployment the maps will have a black screen with the google logo.

What you will need to do is to get 2 api keys from google. One will be used for development and one will be for production. You will need to remember to swap these out before the production deployment.

For development the keystore used to sign the application was here on my machine C:\Users\paulin\.android\debug.keystore

  1. From the command line go there and type. keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android
  2. It will output a fingerprint that you put into here.
  3. The api key it provides you will will need to be installed in your code wherever you use the mapactivity like this.
    
    

Now for production you will end up creating a signing cert that you register with the android store. It too will need a special api key that will allow google maps to be run in your application. So you go through basically the same steps

  1. Go find where your .keystore file lives and type
  2. keytool -list -alias blah -keystore blahkey

  3. Get your fingerprint from the google map web service
  4. Now use that apikey on all your map activities
    
    

Tips

  • One think you might try is to sign your development apk files with the production signature. This could save you a bit of trouble.
  • I think it would be practical to keep this variable in a centralized location so that you can change it in one place. In the current design you would have to change it everwhere you used a mapview