Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puzzling Android xmlns error

Tags:

android

I have come across code like this in many maps examples:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <fragment
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

However, for them all, it goes that I get error

Description Resource Path Location Type Unexpected namespace prefix "xmlns" found for tag fragment activity_msmap.xml /example/res/layout line 8 Android Lint Problem

At line

<fragment xmlns:android="http://schemas.android.com/apk/res/android"

So... What is going on here? I see it in examples everywhere, but it causes error in my Eclipse/Android? Also, why repeat the same xml namespace when it is also defined in the parent element?

like image 534
Tom Avatar asked Apr 11 '26 09:04

Tom


1 Answers

You can't define a namespace twice in an xml layout. Just remove it from your fragment, the RelativeLayout already defines the xmlns:android namespace.

<fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment" />
like image 122
Emanuel Moecklin Avatar answered Apr 12 '26 23:04

Emanuel Moecklin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!