Creating an App Based On Google Maps, Part 1: Obtaining A Google API Key

 

Lately I’ve been finding myself working on a lot of location-sensitive Android applications. Thankfully Google has an open API for their Maps addon to Android that allows you to easily create applications with a Google Map at its base.  Over the next few editions of the Android Development Center we will give you all the tools you need to build a location centric application.

 
Step 1: Set Up Project

  • Fire up eclipse
  • Go to File > New > Project
  • In the resulting dialog box select Android Project
  • Click Next
  • Give your project a name
  • Under build target, select one of the Google APIs targets
  • Fill in the rest as you would for a normal Android application
  • Your “New Android Project” Dialog box should look like this:

 

 

Step 2: Apply for a Google Maps API

Before you can start your application you need a Google Maps API so that you can incorporate Google Maps into your application.  To do this you need to know the signature of the key that will be used to sign your application.  Because we don’t know this yet, we’ll just get an API for the debug key that comes with your SDK.  This will allow Google Maps to work in your testing environment, whether it be in the emulator or a device itself.

Where is this debug key?  It depends on your operating system as follows:

  • Vista (and probably 7)C:\Users\<user>\.android\debug.keystore
  • XPC:\Documents and Settings\<user>\.android\debug.keystore
  • Mac and Linux~/.android/debug.keystore

Open up a terminal and enter the following:

  • Windows: keytool.exe -list -alias androiddebugkey -keystore "Path to debug.keystore" -storepass android -keypass android
  • Linux / Mackeytool -list -alias androiddebugkey -keystore "Path to debug.keystore" -storepass android -keypass android

Copy the result and paste it in the box as shown @ http://code.google.com/android/maps-api-signup.html
 

Signing up for API key

 
A key will be generated for you.  Keep this key; we’re going to use it in the second part of Creating an App Based On Google Maps: Setting up the Map View.
 

Obtaining a key for your Android application