Google Maps For Android

1.Create a new Project “Google Maps”.

2.To make map library part of the standard library ,Open the ‘AndroidManifest.xml’ file and put following code inside the <application> element,

<uses-library android:name="com.google.android.maps" />

3.To take permission from Internet to retrieve a Google Map,in the manifest file put the following code inside the <manifest> element,

<uses-permission android:name="android.permission.INTERNET" />

4.Open the ‘main.xml’ file from res/layout , add the Map View as root node,

<?xml version="1.0" encoding="utf-8"?/>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="Your Maps API Key goes here"/>

5.To generate Maps API key, first create your private key(my-private-key.keystore),go to the Terminal and type following command,

$ keytool -genkey -v -keystore my-private-key.keystore -alias alias_name -keyalg RSA -validity 10000

follow the procedure for each pinged questions and remember the alias and password.

6.Generate MD5 Fingerprint- After generating my-private-key.keystore generate Fingerprint by using following command,

$ keytool -list -alias alias_name -keystore my-private-key.keystore

this command will generate MD5 fingerprint for e.g. like this-
Certificate fingerprint(MD5):94:1E:43:49:87:73:BB:E6:A6:88:D7:20:F1:8E:B5:98

7.Take that MD5 fingerprint and go to the url=>http://code.google.com/android/maps-api-signup.html, you need to agree terms and conditions of android and paste your certificate’s MD5 fingerprint into the text-box and click on ‘Generate API Key’ Button.
your key will generate for e.g. like this-0M3kU2GKEeEbNi9kQxHJWKp3KLMDDfnEM5dv6uw

8.So use your Maps Api Key for project signing with your private key(my-private-key.keystore)-

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0M3kU2GKEeEbNi9kQxHJWKp3KLMDDfnEM5dv6uw"/>

9.Set your Project Properties to 'GoogleApi' for Project Build Target.

10.Open the start activity file 'GoogleMaps.java' and change the extend Activity to Map-Activity,

public class GoogleMaps extends MapActivity {

also override required method isRouteDisplayed(),

@Override
protected boolean isRouteDisplayed() {
return false;
}

11.To set Zoom control on map call the setBuiltInZoomControls(boolean) method in to onCreate() method,

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}

12.Create ‘GoogleMaps.apk’ file To run your application on AVD or device with your private key,sign your application with your my-private-key.keystore. to sign it,right click on application in package explorer or click on Android tools and select ‘Export sign application package’, you will have new window, ‘Export Android Application’, follow the instruction there and sign your application with existing keystore(Step 5),this will generate .apk file for you in your desired location.

13.Install the .apk file on AVD In linux O.S., Open the terminal,and change the directory to android sdk like this-

~$ cd android/android-sdk_(Version)/tools/;

after this start your Virtual device in your eclipse or attach your phone else error will occur ‘device not found’. Use the following command to install apk file on device-

$ ./adb install /(..path to your project)/GoogleMaps.apk

you give your location of .apk file,this way application will get install on your AVD or mobile, to uninstall the application used this command,

$ ./adb uninstall com.wissen.googlemaps (i.e package name)