## Thursday, January 5, 2012

### Android - How to obtain Google API key for Windows ?

There are some steps to obtain a Google API key for windows. The steps are described in detail below.
While you are developing and debugging your application, you will likely be sigining your application in debug mode — that is, the SDK build tools will automatically sign your application using the debug certificate. To let your MapView elements properly display Maps data during this period, you should obtain a temporary Maps API Key registered to the debug certificate. To generate an MD5 fingerprint of the debug certificate, first locate the debug keystore. The default location of debug keystore is

 C:\Documents and Settings\ .android\debug.keystore ( Windows XP ) C:\  Users \ .android \ debug.keystore (Windows 7 / Windows Vista)
If you don’t find debug.keystore in above location, then you can select Windows –> Preferences –> Android –> Build (In case of Eclipse) to check the full path of debug.keystore.
Now navigate the path of keytool.exe in command prompt. keytool.exe is located inside  Java –> JDK – > bin folder inside  program files.In command prompt window write the following command
C:\Program Files\Java\jdk1.6.0_25\bin> keytool -list –alias androiddebugkey -keystore <path_of_debug.keystore> -storepass android -keypass android
The <path_of_debug.keystore> is path of debug.keystore . In my case the path is C:\Users\Pradeep\.android\debug.keystore. It may be different for you. After writing the following command hit enter then result is obtained which is similar to

androiddebugkey, Dec 4, 2011, PrivateKeyEntry,
Certificate fingerprint (MD5): BE:05:C8:F2:42:7A:97:37:78:EE:BD:4A:31:7D:A6:69
Now you will get Google API key

Here is an example xml layout to get you started on your way to mapping glory:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0ZzHJOolD-XzqDu5o4ZU5SBQo66sCis9eNTXd0g"
/>
</LinearLayout>


#### 1 comment:

1. if u r using jdk1.7 than u will need a slightly changed command. explained in the following tutorial.