意外的命名空间“map” - Android Google Maps API [英] Unexpected namespace "map" - Android Google Maps API

查看:112
本文介绍了意外的命名空间“map” - Android Google Maps API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的XML文件的通用性。最重要的部分是地图片段,它给了我这个错误:为标记片段找到了意想不到的名称空间前缀它似乎没有影响代码,但我很好奇,如果有人知道什么是向上。我已经看到帖子称这是一个Lint问题或Eclipse问题,但我使用的是最新版本的Android Studio。

  <?xml version =1.0encoding =utf-8?> 
< LinearLayout xmlns:android =http://schemas.android.com/apk/res/android
android:layout_width =fill_parent
android:layout_height =fill_parent
xmlns:map =http://schemas.android.com/apk/res-auto
android:background =#FFFFFF
android:orientation =vertical>

< LinearLayout
android:layout_width =wrap_content
android:layout_height =wrap_content
android:layout_gravity =center
android:取向= 水平 >

< Button
android:id =@ + id / button_lakeside_webview
android:layout_width =wrap_content
android:layout_height =wrap_content
android:text =Lakeside/>

< Button
android:id =@ + id / button_spinner_webview
android:layout_width =wrap_content
android:layout_height =wrap_content
android:text =Spinner/>

< / LinearLayout>

< LinearLayout
android:layout_width =wrap_content
android:layout_height =wrap_content>

< View
android:id =@ + id / colored_bar
android:layout_width =48dp
android:layout_height =3dp
android:background =/>

< / LinearLayout>

<! - 不确定为什么它会抱怨地图命名空间,下面的代码是Google推荐的 - >

< fragment xmlns:android =http://schemas.android.com/apk/res/android
xmlns:map =http://schemas.android.com / apk / res-auto
android:name =com.google.android.gms.maps.SupportMapFragment
android:id =@ + id / map
android:layout_width =match_parent
android:layout_height =match_parent
map:cameraBearing =0
map:cameraTilt =30
map:cameraZoom =16
map:mapType =normal
map:uiCompass =false
map:uiRotateGestures =false
map:uiScrollGestures =false
map:uiTiltGestures = false
map:uiZoomControls =false
map:uiZoomGestures =false/>

< / LinearLayout>


解决方案

正如您所说,Android中存在已知的错误皮棉。有几个问题提交:



2016年7月14日更新的最后一项声明请再次尝试更新版本的Android Studio(2.2或更高版本),如果问题仍然存在,则会产生新的bug。



作为解决方法,您可以将此属性添加到片段以忽略错误(我测试过了, map:属性按预期工作):

 工具:忽略=缺少前缀


Here's the entirity of my XML file. The imporant part is the map fragment at the end that gives me this error: "Unexpected namespace prefix found for tag fragment" It doesn't seem to impact the code but I'm curious if anyone knows what's up. I've seen posts saying it's a Lint issue or an Eclipse problem but I'm using the latest version of Android Studio.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              xmlns:map="http://schemas.android.com/apk/res-auto"
              android:background="#FFFFFF"
              android:orientation="vertical">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button_lakeside_webview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lakeside"/>

        <Button
            android:id="@+id/button_spinner_webview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Spinner"/>

    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <View
            android:id="@+id/colored_bar"
            android:layout_width="48dp"
            android:layout_height="3dp"
            android:background="" />

    </LinearLayout>

    <!-- Unsure why it complains about the map namespace, the below code is recommended by Google -->

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:map="http://schemas.android.com/apk/res-auto"
              android:name="com.google.android.gms.maps.SupportMapFragment"
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              map:cameraBearing="0"
              map:cameraTilt="30"
              map:cameraZoom="16"
              map:mapType="normal"
              map:uiCompass="false"
              map:uiRotateGestures="false"
              map:uiScrollGestures="false"
              map:uiTiltGestures="false"
              map:uiZoomControls="false"
              map:uiZoomGestures="false"/>

</LinearLayout>

解决方案

As you say there is a known bug in the Android Lint. There are a couple of issues filed:

The last one updated on Jul 14 2016 states that "Please try again on a newer version of Android Studio (2.2 or greater). If the issue still occurs file a new bug."

As a workaround you can add this property to the fragment to ignore the error (I have tested it and the map:properties work as expected):

tools:ignore="MissingPrefix"

这篇关于意外的命名空间“map” - Android Google Maps API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆