2014-09-23 102 views
5

我想在我的android應用程序中使用mapbox。我使用android studio 0.8.0。我已經包括這條線在我的build.gradle文件解析XML時出錯:mapbox的未綁定前綴

compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:[email protected]'){ 
     transitive=true 
    } 
    compile ('com.cocoahero.android:geojson:[email protected]'){ 
     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> 
+1

嘗試把唯一的azazaz =「你的地圖ID密鑰「 – Psypher 2014-09-24 04:31:46

回答

4

好了終於解決了。我改變我的xml文件:

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

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> 
+0

歡呼聲。這有助於 – jonney 2014-10-13 10:51:13

+0

偉大的,這解決了我的問題 – 2015-01-23 18:21:47

+0

@ stephen1706即時通訊也得到同樣的問題錯誤:包'com.example.mapbox'中找不到屬性'mapid'的資源標識符 – Erum 2015-05-14 11:54:34

6

您也可以在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> 
相關問題