0

请有人帮忙,我已经按照我找到的关于在 android 程序/设备上显示 Google Maps API 的每个教程进行操作,但无法使其正常工作。

在我最近的尝试中,我收到运行时错误“无法启动活动 ComponentInfo”

11-06 11:46:36.832: E/AndroidRuntime(24596): FATAL EXCEPTION: main
11-06 11:46:36.832: E/AndroidRuntime(24596): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.maptest/com.example.maptest.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
11-06 11:46:36.832: E/AndroidRuntime(24596):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
11-06 11:46:36.832: E/AndroidRuntime(24596):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)

main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/header"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

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

提前感谢您的任何帮助。

4

2 回答 2

0
Binary XML file line #17: Error inflating class fragment

也许你应该使用

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

代替

android:name="com.google.android.gms.maps.MapFragment"
于 2013-11-06T13:12:57.150 回答
0

我遇到了同样的问题,并通过在清单文件中添加以下行来解决它。

<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
于 2013-12-07T08:21:23.283 回答