0

I am trying to implement simple google maps example I searched about but not clear about the solution Manifest:

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

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

<permission
    android:name="com.syntel.mapexample.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

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

<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required OpenGL ES 2.0. for Maps V2 -->
<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" >
    <activity
        android:name="com.syntel.mapexample.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>

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBllmHwXofzx3N6YpCKmkMXh7rfc4lSL_Q" />
</application>

   </manifest>

XML:

  <fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

   </RelativeLayout>

I am trying to implement simple Map example for viewing the map but getting error

Logcat details:

02-20 10:53:15.706: E/AndroidRuntime(23385): java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.syntel.mapexample/com.syntel.mapexample.MainActivity}: android.view.InflateException: Binary
 XML file line #6: Error inflating class fragment

02-20 10:53:15.706: E/AndroidRuntime(23385):    at 
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
 02-20 10:53:15.706: E/AndroidRuntime(23385):   at 
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
 02-20 10:53:15.706: E/AndroidRuntime(23385):   at 
  android.app.ActivityThread.access$600(ActivityThread.java:141)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at 
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at android.os.Handler.dispatchMessage(Handler.java:99)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at android.os.Looper.loop(Looper.java:137)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at 
  android.app.ActivityThread.main(ActivityThread.java:5041)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at java.lang.reflect.Method.invokeNative(Native Method)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at java.lang.reflect.Method.invoke(Method.java:511)
  02-20 10:53:15.706: E/AndroidRuntime(23385):  at 
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
   02-20 10:53:15.706: E/AndroidRuntime(23385):     at
   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
   02-20 10:53:15.706: E/AndroidRuntime(23385):     at dalvik.system.NativeStart.main(Native Method)
     02-20 10:53:15.706: E/AndroidRuntime(23385): Caused by: android.view.InflateException: Binary XML file 
    line #6: Error inflating class fragment

  02-20 10:53:15.706: E/AndroidRuntime(23385): Caused by: java.lang.IllegalStateException: The meta-data tag in
   your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have 
    the following declaration within the <application> element:     <meta-data 
  android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
poojagupta
  • 982
  • 2
  • 12
  • 26

2 Answers2

1

Add the Google Play services version to your app's manifest

Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

You need to add <meta-data> under <application> tag into your AndroidManifest.xml

....<application>
<meta-data android:name="com.google.android.gms.version"  
android:value="@integer/google_play_services_version" />
</application>

This is because latest google play services requires a version name, which is to be mentioned using <meta-data .. /> inside AndroidManifest.xml

M D
  • 47,665
  • 9
  • 93
  • 114
0

Like the exception says:

You must have the following declaration within the <application> element:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Add it below or above the Google Maps API key

beetstra
  • 7,942
  • 5
  • 40
  • 44