The Maps API key is based on a short form of your application's digital certificate, known as its SHA-1 fingerprint. The fingerprint is a unique text string generated from the commonly-used SHA-1 hashing algorithm. Because the fingerprint is itself unique, Google Maps uses it as a way to identify your application.
To display the SHA-1 fingerprint for your certificate, first ensure that you are using the right certificate. You may have two certificates:
ant
program or Eclipse. You
can also generate this certificate using the keytool
program. Use this
certificate when you are ready to release your app to the world.You can display a certificate's SHA-1 fingerprint using the keytool
program
with the -v
parameter. For more information about Keytool, see the
documentation at
http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html.
Expand the sections below for detailed instructions on how to display your debug or release certificates.
Locate your debug keystore file. The file name is debug.keystore
, and is
created the first time you build your project. By default, it is stored
in the same directory as your Android Virtual Device (AVD) files:
~/.android/
C:\Users\your_user_name\.android\
If you are using Eclipse with ADT, and you're not sure where your debug keystore is located, you can select Windows > Prefs > Android > Build to check the full path, which you can then paste into a file explorer to locate the directory containing the keystore.
List the SHA-1 fingerprint.
For Linux or OS X, open a terminal window and enter the following:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
For Windows Vista and Windows 7, run:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
You should see output similar to this:
Alias name: androiddebugkey
Creation date: Jan 01, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4aa9b300
Valid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033
Certificate fingerprints:
MD5: AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9
SHA1: BB:0D:AC:74:D3:21:E1:43:07:71:9B:62:90:AF:A1:66:6E:44:5D:75
Signature algorithm name: SHA1withRSA
Version: 3
The line that begins SHA1
contains the certificate's SHA-1 fingerprint.
The fingerprint is the sequence of 20 two-digit hexadecimal numbers
separated by colons.
Locate your release certificate keystore file. There is no default location
or name for the release keystore. If you don't specify one when you build
your application for release, the build will leave your .apk
unsigned,
and you'll have to sign it before you can publish it.
For the release certificate, you also need the certificate's alias and the
passwords for the keystore and the certificate. You can list the aliases
for all the keys in a keystore by entering:
keytool -list -keystore your_keystore_name
Replace your_keystore_name
with the fully-qualified path and name of
the keystore, including the .keystore
extension. You'll be prompted for
the keystore's password. Once you enter it, keytool
displays all the
aliases in the keystore.
Enter the following at a terminal or command prompt:
keytool -list -v -keystore your_keystore_name -alias your_alias_name
Replace your_keystore_name
with the fully-qualified path and name of
the keystore, including the .keystore
extension. Replace
your_alias_name
with the alias that you assigned to the certificate
when you created it.
Caution: To protect your keystore and key, don't
enter the storepass
or keypass
arguments on the command line unless
you're confident of your computer's security. For example, on a public
computer, someone could look at your terminal window history or list
of running processes, get the password, and then have write access
to your signing certificate. This would allow that person to modify
or replace your application with their own.
You should see a display that is similar to this:
Alias name: <alias_name>
Creation date: Feb 02, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4cc9b300
Valid from: Mon Feb 02 08:01:04 UTC 2013 until: Mon Feb 02 18:05:04 PST 2033
Certificate fingerprints:
MD5: AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6B:AC:F9
SHA1: BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:90:AF:A1:66:6E:44:5D:75
Signature algorithm name: SHA1withRSA
Version: 3
The line that begins SHA1
contains the certificate's SHA-1 fingerprint.
The fingerprint is the sequence of 20 two-digit hexadecimal numbers
separated by colons.
Follow these steps to create or modify a project for your application in the Google APIs Console and register for the Maps API.
If your application is registered with the Google Maps Android API v2 service, then you can request an API key. It's possible to register more than one key per project.
In the resulting dialog, enter the SHA-1 fingerprint, then a semicolon, then your application's package name. For example:
BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75;com.example.android.mapexample
The Google APIs Console responds by displaying Key for Android apps (with certificates) followed by a forty-character API key, for example:
AIzaSyBdVl-cTICSwYKrZ95SuvNw7dbMuDt1KG0