【问题标题】:Error parsing XML: unbound prefix for mapbox解析 XML 时出错:mapbox 的未绑定前缀
【发布时间】:2014-09-23 03:07:29
【问题描述】:

我正在尝试在我的 android 应用程序中使用 mapbox。我使用安卓工作室 0.8.0。我已将这一行包含在我的 build.gradle 文件中

    compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.4.0@aar'){
        transitive=true
    }
    compile ('com.cocoahero.android:geojson:1.0.0@aar'){
        transitive=true
    }

但是当我在我的 xml 文件中使用它时,它有一个命名空间错误。 mapbox 命名空间导致了这一点。知道是什么原因造成的吗?

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/parent_layout">
    <LinearLayout
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:textSize="15sp"
            android:text="this is the general tab"/>
        <com.mapbox.mapboxsdk.views.MapView -->not causing error
            android:id="@+id/mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            mapbox:mapid="Your MapBox mapid" /> -->causing error
    </LinearLayout>
</ScrollView>

【问题讨论】:

  • 试着只放 mapid="your map id key"

标签: android xml android-studio mapbox


【解决方案1】:

您也可以通过在 xml 中添加以下行来修复此错误:

xmlns:mapbox="http://schemas.android.com/apk/res-auto"

XML 示例:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:mapbox="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >


    <com.mapbox.mapboxsdk.views.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        mapbox:mapid="your id" />

</LinearLayout>

【讨论】:

    【解决方案2】:

    好的,终于解决了。我更改了我的 xml 文件:

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/parent_layout">
        <com.mapbox.mapboxsdk.views.MapView
            android:id="@+id/mapid"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:paddingTop="10dp"
            app:mapid="your map id"
            android:layout_width="match_parent"
            android:layout_height="320dp" >
        </com.mapbox.mapboxsdk.views.MapView>
    </ScrollView>
    

    【讨论】:

    • @stephen1706 我也遇到了同样的问题错误:在包'com.example.mapbox'中找不到属性'mapid'的资源标识符
    • 在 Eclipse 中使用了相同的代码,但仍然是同样的问题
    • @stephen1706 05-15 11:05:10.352:E/MapboxUtils(15841):缺少令牌 05-15 11:05:10.352:E/MapboxUtils(15841):com.mapbox.mapboxsdk。 exceptions.MissingTokenException:需要访问令牌才能使用 Mapbox API。在 mapbox.com/account/apps 的 Mapbox 帐户页面上获取令牌。
    猜你喜欢
    • 2015-01-27
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多