Get the SHA-1 Certificate Fingerprint
The Google Maps Android API v2 uses “SHA-1 certificate fingerprint” to obtain the API key. This SHA-1 fingerprint generate from keytool can only be used for testing and not for publishing the application.
Through Eclipse:
If you are using the Eclipse IDE, Goto Windows –> Preferences –> Select ‘Build’ under ‘Android’. You can get the SHA-1 fingerprint from there.
Through Command Prompt:
- The .android folder at Users contains the debug.keystore file.
2. Open cmd from .android and enter the following command.
keytool -list -alias androiddebugkey -keystore <path to debug.keystore> -storepass android -keypass android
example:
keytool -list -alias androiddebugkey -keystore C:\Users\Tharaka\.android\debug.keystore -storepass android -keypass android
Get the Google Maps Android API v2 Key
The SHA-1 fingerprint is used to register the application and to obtain the Map API v2 key.
- Goto –> Google API Console (https://code.google.com/apis/console/) –> Select “Create Project”.
2. New “API Project” will be added to the “Google Developers Console”(redirect to page: https://console.developers.google.com/project ).
3. Select “APIs & auth” –> From available “APIs” –> Select “Google Maps Android API v2”
4. Click on “OFF” button –> Enable Agree Terms of Use –>Accept
5. Select “Credentials” –> Create New Key –> Select “Android Key”
6. Add the “SHA-1 fingerprint” and the “package name” in the blank space according to the guidelines available. Click on “Create”.
7. You will get the Key for Android application on the Google Console.
Note:
This Map API key should be added to the AndroidMainfest.xml file as meta-data under <application> element
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>
Happy Coding 🙂