与Map标签相关的Google MapV2错误

时间:2014-02-20 11:28:35

标签: android google-maps

我正在尝试实现简单的谷歌地图示例我搜索但不清楚解决方案 清单:

<?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>

我正在尝试实现简单的Map示例来查看地图但收到错误

Logcat详细信息:

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" />

2 个答案:

答案 0 :(得分:1)

将Google Play服务版本添加到您应用的清单

  

编辑应用程序的AndroidManifest.xml文件,然后添加   在元素中声明如下。这嵌入了版本   使用该应用编译的Google Play服务。

您需要将<meta-data>标记下的<application>添加到AndroidManifest.xml

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

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

答案 1 :(得分: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" />

将其添加到Google Maps API密钥的下方或上方