Friday, July 22, 2016

[Android][Resolved] Android Studio unexpected namespace prefix map

After rebuild or clean the project, still get this message: 


Error message :
Unexpected namespace prefix "map" found for tag fragment
The reason why case that is because you haven't import the correct namespace:



Check that if you got the attribute "xmlns:map" at your root xml element of your layout file, and then:

Case 1 ) If there is no "xmlns:map" attribute 

if you are using windows Platform,  press "alt" and also "Enter" to import namespace. However, be ware not to import the first one, choose "http://schemas.android.com/tools" as your option.

 

Case 2) If there is "xmlns:map" attribute

just change the value of "http://schemas.android.com/apk/res-auto" to "http://schemas.android.com/tools" at your "xmlns:map" attribute of root tag, for an example:

<?xml version="1.0" encoding="utf-8"?>
    <!-- <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/textContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_weight="1"
        android:orientation="vertical"> -->

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/tools"
        android:id="@+id/textContainer"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_weight="1"
        android:orientation="vertical">

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.SupportMapFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            map:cameraTargetLat="44.22438242"
            map:cameraTargetLng="6.944561"
            map:cameraZoom="10"/>

    </LinearLayout>

Finally run your project again.

Reference:

http://stackoverflow.com/questions/16991927/android-studio-xmlnsmap-not-working

No comments :

Post a Comment