Java 使用API maps v2扩展视图时出现的问题

Java 使用API maps v2扩展视图时出现的问题,java,android,google-maps,maps,Java,Android,Google Maps,Maps,您好,我正在尝试为我的应用程序使用Google Maps Api,我只想显示地图,但我的日志显示: 11-19 14:40:51.679: E/ActivityThread(18815): Failed to inflate 11-19 14:40:51.679: E/ActivityThread(18815): android.view.InflateException: Binary XML file line #2: Error inflating class fragment 以下是完

您好,我正在尝试为我的应用程序使用Google Maps Api,我只想显示地图,但我的日志显示:

11-19 14:40:51.679: E/ActivityThread(18815): Failed to inflate
11-19 14:40:51.679: E/ActivityThread(18815): android.view.InflateException: Binary XML file line #2: Error inflating class fragment
以下是完整的日志:

这是我的activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/map"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:name="com.google.android.gms.maps.MapFragment"/>

这是我的清单:

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

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

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

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
 Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.mapps.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="**key**"/>
</application>

我的mainActivity.java没有任何额外的代码 如果有人知道问题出在哪里,我将不胜感激,而不是:

android:name="com.google.android.gms.maps.MapFragment"
试试这个:

class="com.google.android.gms.maps.MapFragment" 
见:

并检查您是否已将Google Play服务设置为项目中的库。您可以这样做:


您可以阅读以下答案来帮助您:

您是否将google services作为android库引用?是的,我想,我该如何做?它会向我抛出以下错误:错误:在包“android”中未找到属性“class”的资源标识符您需要设置构建目标(例如Eclipse中的属性>android)在您的Build sdk版本上使用API Google Services。请参阅我的更新答案。