Modify AndroidManifest.xml for Google Maps Android API v2

To use Google Maps Android API v2 on your app, you have to modify your AndroidManifest.xml as listed below:
  • Insert <meta-data> element to include API key as a child of the <application>

    <meta-data
    android:name="com.google.android.maps.v2.API_KEY"
    android:value="--- your API Key here ---"/>


    Remember to replace value with your own API Key.

    Please notice that you have to use debug API Key (refer to "Generate Debug API Key for Google Maps Android API v2 service") in your testing. And then replace with release API key (refer to "Create and Obtain API Key for Google Maps Android API v2 service") in your release APK.
  • Add <permission> and <uses-permission> of MAPS_RECEIVE.

    <permission
    android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"></permission>
    <uses-permission
    android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"/>


    where com.example.androidmapsv2 is my package, replace with your own package name.

  • Add uses-permission:

    <uses-permission
    android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <uses-permission
    android:name="android.permission.INTERNET"/>
    <uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


    and optional:

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


  • Specify uses-feature of OpenGL ES 2:

    <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>


Finally, the AndroidManifest.xml will like it:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.androidmapsv2"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />

<permission
android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature"></permission>
<uses-permission
android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="--- your API Key here ---"/>
<activity
android:name="com.example.androidmapsv2.MainActivity"
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>

</manifest>



The series:
A simple example using Google Maps Android API v2, step by step.