5

I'm trying to use mapbox in my android application. I use android studio 0.8.0. I've included this line in my build.gradle file

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

But when I'm using it in my xml file, it has a namespace error. the mapbox namespace causes that. any idea what might cause that?

<?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>
stephen1706
  • 1,010
  • 11
  • 22

2 Answers2

10

You can also fix this error by adding this line in your xml:

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

XML example:

<?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>
nillas
  • 431
  • 3
  • 4
5

okay finally it is solved. I change my xml file :

<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
  • 1,010
  • 11
  • 22
  • @stephen1706 i m also getting same issue error: No resource identifier found for attribute 'mapid' in package 'com.example.mapbox' – Erum May 14 '15 at 11:54
  • have used same code in eclipse but still same issue – Erum May 14 '15 at 11:54
  • @stephen1706 05-15 11:05:10.352: E/MapboxUtils(15841): Missing Token 05-15 11:05:10.352: E/MapboxUtils(15841): com.mapbox.mapboxsdk.exceptions.MissingTokenException: An access token is required in order to use the Mapbox API. Obtain a token on your Mapbox account page at https://www.mapbox.com/account/apps/. – Erum May 15 '15 at 06:10