Open a command prompt and navigate to a file called debug.keystore.
The location of this file depends on what OS you are using. I use
Windows XP and my debug.keystore file is located at C:\Documents
and Settings\User\.android.
As a side note, before the Android 1.5 SDK came out, my debug.keystore file was located in a different location (C:\Documents and Settings\HP_Administrator\Local Settings\Application Data\Android). When I later updated to 1.5 I ran into all sorts of problems getting the maps to work.
if you use a Mac or Linux OS, I've discovered that you'll find the debug.keystore file at:
The debug.keystore contains a digitial certificate that android uses to launch applications on the emulator. The certificate is called 'androiddebugkey'. We'll need to get some an MD5 hash for this certificate in order register for our map api key.
Hopefully you've located the debug.keystore file, so now we'll use Java's keytool utility to get the MD5.
I use XP so I navigated to the proper directory by opening a command prompt and typing:
cd C:\Documents and Settings\HP_Administrator\.android
Once you've navigated to the proper directory for your os, type this in...
keytool -list -alias androiddebugkey -storepass android -keypass android -key
store debug.keystore
Once you hit the enter key, you'll see something like this (the actual MD5 that we're interested in is the last line):
androiddebugkey, Mar 10, 2009, PrivateKeyEntry,
Certificate fingerprint (MD5): D1:16:4A:BD:73:73:A4:56:9D:CD:9A:44:A2:6C:11:AC
Now open your browser and go to the following url...
http://code.google.com/intl/ja/android/maps-api-signup.html
Accept the agreement and paste the md5 that the key tool returned to you, in my case it was something like...
D1:16:4A:BD:73:73:A4:56:9D:CD:9A:44:A2:6C:11:AC
Then press "Generate API Key" and you'll be redirected to a page that has your api key.
Now
that you have the api key, you can use it in the main.xml layout file
of your MapTest application. Here's what mine looks like:
<?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">
<com.google.android.maps.MapView
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0q7NUYm4bgzeXlqXtKYVPJDRWUJmt8Cu0gvbWMx"
/>
</LinearLayout>
You'll also have to add some entries to your manifest file, here's what mine looks like...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.remwebdevelopment.maptest"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- this was the kicker - had to import the library com.google.android.maps!!! -->
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!--make sure you add the following permissions to your app!!!-->
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET">
</uses-permission>
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.ACCESS_FINE_LOCATION">
</uses-permission>
</manifest>
Here's what my MapActivity looks like(note that it extends MapActivity, not Activiy)...
package com.remwebdevelopment.maptest;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class MapTest extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//you could get a reference to the map view from the main.xml
//layout like this...
//mMapView = (MapView)findViewById(R.id.mapview1);
}
//you must provide an implementation for isRouteDisplayed()
//when you extend MapActivity...
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
You should see a map of the world when you run it.
Hopefully this will get you up and running.
___________________________________________________________________________
--------------- For Windows 7 below shows that api key genarate in command prompt some difference from windows XP.. see
set Map.xml as below
<com.google.android.maps.MapView
android:id="@+id/mapview1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0nzYV_RaZTPJJhNG95A29exaNtxyCxKr5Y_EC3A"
/>
I have other code samples
that might be helpful, I'll be posting them soon.
----------------------------------------------------------------------------------------------------------------
Those are the steps that you have to follow for the obtain API key. You should copy this key and save for future use. This key can be use in any kind of Android Google Map applications.
As a side note, before the Android 1.5 SDK came out, my debug.keystore file was located in a different location (C:\Documents and Settings\HP_Administrator\Local Settings\Application Data\Android). When I later updated to 1.5 I ran into all sorts of problems getting the maps to work.
if you use a Mac or Linux OS, I've discovered that you'll find the debug.keystore file at:
~/.android/
.
The debug.keystore contains a digitial certificate that android uses to launch applications on the emulator. The certificate is called 'androiddebugkey'. We'll need to get some an MD5 hash for this certificate in order register for our map api key.
Hopefully you've located the debug.keystore file, so now we'll use Java's keytool utility to get the MD5.
I use XP so I navigated to the proper directory by opening a command prompt and typing:
cd C:\Documents and Settings\HP_Administrator\.android
Once you've navigated to the proper directory for your os, type this in...
keytool -list -alias androiddebugkey -storepass android -keypass android -key
store debug.keystore
Once you hit the enter key, you'll see something like this (the actual MD5 that we're interested in is the last line):
androiddebugkey, Mar 10, 2009, PrivateKeyEntry,
Certificate fingerprint (MD5): D1:16:4A:BD:73:73:A4:56:9D:CD:9A:44:A2:6C:11:AC
Now open your browser and go to the following url...
http://code.google.com/intl/ja/android/maps-api-signup.html
Accept the agreement and paste the md5 that the key tool returned to you, in my case it was something like...
D1:16:4A:BD:73:73:A4:56:9D:CD:9A:44:A2:6C:11:AC
Then press "Generate API Key" and you'll be redirected to a page that has your api key.
Now
that you have the api key, you can use it in the main.xml layout file
of your MapTest application. Here's what mine looks like:
<?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">
<com.google.android.maps.MapView
android:id="@+id/mapview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0q7NUYm4bgzeXlqXtKYVPJDRWUJmt8Cu0gvbWMx"
/>
</LinearLayout>
You'll also have to add some entries to your manifest file, here's what mine looks like...
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.remwebdevelopment.maptest"
android:versionCode="1"
android:versionName="1.0.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- this was the kicker - had to import the library com.google.android.maps!!! -->
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MapTest"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<!--make sure you add the following permissions to your app!!!-->
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.INTERNET">
</uses-permission>
<uses-permission
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="android.permission.ACCESS_FINE_LOCATION">
</uses-permission>
</manifest>
Here's what my MapActivity looks like(note that it extends MapActivity, not Activiy)...
package com.remwebdevelopment.maptest;
import com.google.android.maps.MapActivity;
import android.os.Bundle;
public class MapTest extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//you could get a reference to the map view from the main.xml
//layout like this...
//mMapView = (MapView)findViewById(R.id.mapview1);
}
//you must provide an implementation for isRouteDisplayed()
//when you extend MapActivity...
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
You should see a map of the world when you run it.
Hopefully this will get you up and running.
___________________________________________________________________________
--------------- For Windows 7 below shows that api key genarate in command prompt some difference from windows XP.. see
C:\Program Files\Java\jre7\bin>keytool.exe -list -v
-alias androiddebugkey -keys
tore "C:\Users\Student\.android\debug.keystore"
-storepass android -keypass andr
oid
Alias name: androiddebugkey
Creation date: ?? ??????, ????
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[?]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 17ddf75
Valid from: Tue Apr 17 14:01:44 IST 2012 until: Thu Apr 10
14:01:44 IST 2042
Certificate fingerprints:
MD5:
27:CB:33:C0:89:44:60:BD:82:25:D0:C6:A0:ED:56:E0
SHA1:
6C:D4:C8:FC:A8:46:D1:3F:1C:C8:01:65:65:6F:6C:66:FE:9A:9A:11
SHA256:
8C:43:A0:7C:E3:3A:DD:A7:66:1E:53:12:0C:E2:77:60:4E:3E:84:C5:D6:
CF:CB:C0:5A:0A:4A:B4:62:2E:2B:DC
Signature algorithm name: SHA256withRSA
Version: ?
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: D3 1B 80 EC 41 1F 77 BA CB 1F C1 46 36 84 1D DB ....A.w....F6...
0010: 41 90 9B D6
A...
]
]
C:\Program Files\Java\jre7\bin>
set Map.xml as below
<com.google.android.maps.MapView
android:id="@+id/mapview1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0nzYV_RaZTPJJhNG95A29exaNtxyCxKr5Y_EC3A"
/>
I have other code samples
that might be helpful, I'll be posting them soon.
----------------------------------------------------------------------------------------------------------------
Obtain certificate’s fingerprint in Windows 7
- First go
to C:\Users\username\.android directory there is file called debug.keystore
we are going to use this file to generate certificate’s
fingerprint.
- Open command prompt and enter following command on that
keytool.exe -list -alias androiddebugkey -keystore "C:\Users\yourusername\.android\debug.keystore"
-storepass android -keypass android
Obtain certificate’s fingerprint in Mac OSX or Linux
- In
Linux or Mac OSX debug.keystore is in ~/.android
directory
- Open terminal and enter following command on that
keytool -list -keystore ~/.android/debug.keystore
Then it will give certificate fingerprint like following
12:50:7F:C0:10:F0:A7:24:13:49:BF:42:76:76:38:83After all go to the following site for obtaining Map API key
http://code.google.com/android/maps-api-signup.htmlFollow the steps given bellow for obtain Map API key
Those are the steps that you have to follow for the obtain API key. You should copy this key and save for future use. This key can be use in any kind of Android Google Map applications.
No comments:
Post a Comment