frequent issues arising in android view, Error parsing XML: unbound prefix

The question:

I have frequent problem in android view, Error parsing XML: unbound prefix on Line 2.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/myScrollLayout" 
android:layout_width="fill_parent"  android:layout_height="wrap_content">
    <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" 
    android:text="Family" android:id="@+id/Family" 
    android:textSize="16px" android:padding="5px" 
    android:textStyle="bold" android:gravity="center_horizontal">

    <ScrollView xmlns:android=""
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:orientation="vertical" android:scrollbars="vertical">
        <LinearLayout android:orientation="vertical" android:id="@+id/myMainLayout" 
        android:layout_width="fill_parent"  android:layout_height="wrap_content">


The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

A couple of reasons that this can happen:

1) You see this error with an incorrect namespace, or a typo in the attribute. Like ‘xmlns’ is wrong, it should be xmlns:android

2) First node needs to contain:

3) If you are integrating AdMob, check custom parameters like ads:adSize, you need


4) If you are using LinearLayout you might have to define tools:


Method 2

I’m going to add a separate answer just because I don’t see it here. It’s not 100% what Pentium10 asked for, but I ended up here by searching for Error parsing XML: unbound prefix

Turns out I was using custom parameters for AdMob ads like ads:adSize, but I hadn’t added


to the layout. Once I added it it worked great.

Method 3

I had this same problem.

Make sure that the prefix (android:[whatever]) is spelled correctly and written correctly. In the case of the line xmlns:android=""
make sure that you have the full prefix xmlns:android and that it is spelled correctly. Same with any other prefixes – make sure they are spelled correctly and have android:[name]. This is what solved my problem.

Method 4

As you mention, you need to specify the right namespace. You also see this error with an incorrect namespace.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns=""

will not work.





The error message is referring to everything that starts “android:” as the XML does not know what the “android:” namespace is.

xmlns:android defines it.

Method 5

This error may occurs in the case you use un-defined prefix such as:

<LinearLayout xmlns:android=""
android:orientation="vertical" >

    android:layout_height="fill_parent" >


Android compiler does not know what is XYZ since it was not defined yet.

In your case, you should add below define to root node of the xml file.


Method 6

unbound prefix error for ViewPager Indicator:

Along with the following header tags in your parentLayout:


Also add:


This did the trick for me.

Method 7

For me, I got the “unbound prefix” error on first line here, although I had misspelled android on the fourth line.

<ScrollView xmlns:android=""

Method 8

I had the same problem, and found that the solution was to add the android:tools to the first node. In my case it is a LineraLayout:

    <LinearLayout xmlns:android=""

Method 9

I’ll throw in a little more for the newbies and for folks, like myself, that don’t understand XML.

The answers above a pretty good, but the general answer is that you need a namespace for any namespace used in the config.xml file.

Translation: Any XML tag name that has is a tag with a namespace where blah is the namespace and fubar is the XML tag. The namespace lets you use many different tools to interpret the XML with their own tag names. For example, Intel XDK uses the namespace intelxdk and android uses android. Thus you need the following namespaces or the build throws up blood (i.e. Error parsing XML: unbound prefix) which is translated to: You used a namespace, but did not define it.


Method 10

OK, there are lots of solutions here but non actually explain the root cause of the problem so here we go:

when you see an attribute like android:layout_width="match_parent" the android part is the prefix, the format for an attribute here is PREFIX:NAME="VALUE". in XML, namespaces and prefixes are ways to avoid naming conflicts for example we can have two distinct attributes with same name but different prefixes like: a:a="val" and b:a="val".

to use prefixes like android or app or any other your should define a namespace using xmlns attribute.

so if you have this issue just find prefixes that do not have a namespace defined, if you have tools:... you should add tools namespace as some answeres suggested, if you have app:... attribute you should add xmlns:app="" to the root element

Further reading:

XML Namespaces simple explanation

XML Namespaces in W3

Method 11

This error usually occurs if you have not included the xmlns:mm properly, it occurs usually in the first line of code.

for me it was..


that i missed in first line of the code

<RelativeLayout xmlns:android=""
android:background="@android:color/transparent" >

Method 12

You just need to add proper name space in your root tag .
Android elemets are declared in this name space.Its same as importing class or package.

Method 13

In my case the error was not caused by any of the above xml namespace issues. Instead it was the location of the android:id attribute – it needed to be the first item in the particular element’s declaration.

So this:

<TextView android:layout_width="fill_parent" 
      android:singleLine="true" />

… needed to read like this:

<TextView android:id="@+id/bottomtext" 
      android:singleLine="true" />

Method 14

Beside all this, There is also a scenario where this error occures-

When you or your library project define custom attribute int attr.xml, And you use these attributes in your layout file without defining namespace .

Generally we use this namespace definition in header of our layout file.


Then make sure all attributes in your file shoud start with


You need to identfy if some of your attirbute is not starting with something other than android:ATTRIBUTE-NAME like


In this case you have this “temp” also as namespace, generally by including-


Method 15

It usually happens to me when I misspell android – I just type andorid or alike, and it’s not obvious at first sight especially after many hours of programming, so I just do a search for “android” one by one and see if search skips one tag – if it does then I have a close look and I see where was typo.

Method 16

I got this error in Xamarin when I was using


in a layout file without installing the nuget package for

Installing the applicable nuget package fixed the issue. Hope it helps, I didn’t see this answer anywhere in the list

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment