Pages

Minimum required to get started with Google Maps

1) Obtain key for debug version of app.
The default location where the MD5 certificate is stored for the Debug version of the app:
C:\Users\<your windows user>\.android\debug.keystore


The keytool.exe is here:
C:\Program Files\Java\jdk1.6.0_14\bin


The command to get the debug certificate is:
keytool -list -alias androiddebugkey -keystore C:\Users\<your windows user>\.android\debug.keystore -storepass android -keypass android


Enter the MD5 cetificate output by the keytool command into the Google Maps signup page: http://code.google.com/android/maps-api-signup.html

2) Add the highlighted lines to AndroidManifest.xml

<application android:icon="@drawable/icon" android:label="@string/app_name">
...
<uses-library android:name="com.google.android.maps" />
...
</application>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />


3) Create an Activity that extends MapActivity otherwise LogCat reports this error:

09-06 07:44:23.269: ERROR/AndroidRuntime(868): Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.


package xxx.yyy;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class MyMapView extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
}

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


4) Create a layout (mapview.xml) in this example

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<com.google.android.maps.MapView
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:apiKey="the key received from Google" />
</LinearLayout>


5) Remember to add the MyMapView activity to the project's AndroidManifest.xml

6) Using the project's Properties dialog, select Android and choose the target as Google APIs

7) Using the AVD Manager create a new AVD that targets Google APIs