【问题标题】:Android Google Maps: XML layout errorsAndroid 谷歌地图:XML 布局错误
【发布时间】:2013-08-24 14:37:38
【问题描述】:

我正在尝试使用 android studio 让 google maps v2 在 android 中工作。我得到了所有的密钥和清单设置。当我尝试为地图将显示的实际活动创建 xml 时,我得到了错误。我的 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"
                tools:context=".MainActivity" >

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              class="com.google.android.gms.maps.SupportMapFragment"/>
</RelativeLayout>

我在 android studio 中的错误如下所示:

【问题讨论】:

  • 您需要包含 google play 服务库。
  • 看看我的回答可能会有所帮助。

标签: android xml android-mapview android-studio android-maps-v2


【解决方案1】:

这也发生在我身上。只需清理项目即可。

【讨论】:

  • 我不熟悉 Android Studio,但对于 eclipse 它的 Project-> clean。您可能需要遵循这些说明。 stackoverflow.com/questions/17135099/…
  • 我发现一个教程说 rebuuild 与 android studio 中的 clean 相同,但它没有解决我的问题
【解决方案2】:

您好,您必须在 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="fill_parent"
          android:layout_height="fill_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

【讨论】:

  • 这看起来与问题中的fragment 非常相似。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多