【问题标题】:Cannot get Android Maps API working - Unable to start activity ComponentInfo无法让 Android 地图 API 工作 - 无法启动活动 ComponentInfo
【发布时间】:2013-11-06 12:24:35
【问题描述】:

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

在我最近的尝试中,我遇到了运行时错误“无法启动活动组件信息”

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

感谢您的任何帮助。

【问题讨论】:

  • 你可以发布你的课程文件吗?

标签: android google-maps runtimeexception


【解决方案1】:
Binary XML file line #17: Error inflating class fragment

也许你应该使用

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

代替

android:name="com.google.android.gms.maps.MapFragment"

【讨论】:

  • 感谢您的建议,刚刚替换了该行,我在 logCat "Error inflating class fragment" 上得到完全相同的错误消息
【解决方案2】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    • 1970-01-01
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多