Android Google Maps fragment in the xml. I get "Unexpected namespace prefix"

Alex picture Alex · Feb 22, 2013 · Viewed 31.5k times · Source

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>

Answer

Kent picture Kent · Apr 20, 2013

I had this problem as well. I did Project/Clean and the error went away and it works fine now.