Error parsing XML: unbound prefix on library

I am using three libraries in my project:

a. ViewPager
b. SherlockActionBar
c. PagerSlidingTabStrip

In my layout xml, I am getting the following error parsing XML in here:

<com.astuetz.viewpager.extensions.PagerSlidingTabStrip
    android:id="@+id/strips"
    android:layout_width="match_parent"
    android:layout_height="48dip"
    app:indicatorColor="#FF9326"
    app:textAllCaps="false" />

I implemented the library same as the two other libraries used in the project. The other two libraries are running smoothly. Error only exists within this. Please help.

Full layout xml:

<LinearLayout 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"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainSlider" >

    <com.astuetz.viewpager.extensions.PagerSlidingTabStrip
        android:id="@+id/strips"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        app:indicatorColor="#FF9326"
        app:textAllCaps="false" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>

I have already tried cleaning the project, re-adding library to the workspace, etc.

Answers


Try to add custom properties reference using res-auto xmlns schemas

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainSlider" >

    <com.astuetz.viewpager.extensions.PagerSlidingTabStrip
        android:id="@+id/strips"
        android:layout_width="match_parent"
        android:layout_height="48dip"
        app:indicatorColor="#FF9326"
        app:textAllCaps="false" />

    <android.support.v4.view.ViewPager
        android:id="@+id/pager"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>

Add

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

to the root layout of the xml.


I didn't have a LinearLayout as my root XML element. I had an android.support.v4.view.ViewPager instead because I was using the AppCompat Library.

So, this was what I did: ** I included the tools:context=".classname" line and that's where the Error parsing XML: unbound prefix comes from (in part). It's brought about when you referrence a path that Eclipse/Studio can't see when it's building your xml layout.

Solution: I added the xmlns:tools="http://schemas.android.com/tools" to point ADT to my tools location, and we were good to go!

FINAL CODE:

<android.support.v4.view.ViewPager 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/pager"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context=".home"
    />

Root element of every xml have to contain:

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

And you can use android attributes after.


there is already a root element

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context="com.example.arifa.model.MainActivity"
android:weightSum="1">

Remove and add this again:

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

Then clean and build the project.


Need Your Help

Install Mono and Monodevelop on CentOS 5.x/6.x

linux mono centos monodevelop

I am trying to install Mono and Monodevelop on a CentOS 5.9 environment.

How do I create a configure script?

linux bash makefile configure

This may sound like a very generic question but here it goes.