Android的谷歌地图片段中的XML。我得到"意外的命名空间preFIX"片段、意外、地图、空间

2023-09-05 06:42:34 作者:My City is king我城我为王

我想学习Android和已经跟随了如何使用谷歌地图API V.2现在我懂了工作的指示。 然而,关于如何配置的地图的初始状态的指示,发现了在developers.google.com,建议在XML文件中定义的命名空间,在这种情况下,地图。

该XML的$ C $低于C给出配有错误的意外的命名空间preFIX地图。试图定义的的xmlns:地图片段标记中作出了同样的错误,但用的xmlns。

我明明在这里缺少一些基本的XML知识,有人可以帮我吗?

 < RelativeLayout的
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    的xmlns:工具=htt​​p://schemas.android.com/tool​​s
    的xmlns:地图=htt​​p://schemas.android.com/apk/res-auto<  - 定义 - >
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>

    <片段
        机器人:ID =@ + ID /图
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        类=com.google.android.gms.maps.SupportMapFragment
        图:cameraBearing =112.5/> <! - 问题 - >

< / RelativeLayout的>
 

解决方案

您需要做两件事情:

第一: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

添加到依赖谷歌播放服务到您的项目

 项目 - >属性 - > Android的 - >图书馆,添加 - >谷歌播放的,services_lib
 
对比 iOS 14.5 最强更新功能,Android 系统做得怎么样

第二个: https://developers.google.com/maps/documentation/android/intro

选择项目>属性,选择Java Build Path,并导航到库。 选择添加外部JAR,包括以下jar文件,然后单击确定:

 < Android的SDK文件夹> /extras/android/compatibility/v4/android-support-v4.jar
 

现在我的项目显示了没有错误:) 问候,烫发

I'm trying to learn android, and having followed the instructions on how to use the Google Maps API V.2 I now got it working. However, the instructions on how to configure the initial state of the maps, found at developers.google.com, suggests a namespace defined in the xml-file, in this case "map".

The xml-code below gives med the error "Unexpected namespace prefix "map"". Trying to define the xmlns:map inside the fragment tag gave the same error but with "xmlns".

I'm obviously missing some fundamental xml-knowledge here, can someone help me out?

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"        
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:map="http://schemas.android.com/apk/res-auto"      <!-- Definition -->
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment 
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"
        map:cameraBearing="112.5"/>                            <!-- PROBLEM -->

</RelativeLayout>

解决方案

you have to do two things:

first: https://docs.google.com/document/pub?id=19nQzvKP-CVLd7_VrpwnHfl-AE9fjbJySowONZZtNHzw

Add the dependency to Google Play Services into your project

Project -> Properties -> Android -> Library, Add -> google-play-services_lib

second: https://developers.google.com/maps/documentation/android/intro

Select Project > Properties, select Java Build Path, and navigate to Libraries. Select Add External Jars, include the following jar files, and click OK:

<android-sdk-folder>/extras/android/compatibility/v4/android-support-v4.jar

now my project shows no errors anymore :) regards, marcel