Error parsing XML: unbound prefix on library

前端 未结 6 2248
感情败类
感情败类 2021-02-19 01:56

I am using three libraries in my project:

a. ViewPager
b. SherlockActionBar
c. PagerSlidingTabStrip

In my layout xml, I am getting the followin

相关标签:
6条回答
  • 2021-02-19 02:22

    Add

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

    to the root layout of the xml.

    0 讨论(0)
  • 2021-02-19 02:32

    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"
        />
    
    0 讨论(0)
  • 2021-02-19 02:33

    Root element of every xml have to contain:

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

    And you can use android attributes after.

    0 讨论(0)
  • 2021-02-19 02:37

    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">
    
    0 讨论(0)
  • 2021-02-19 02:43

    Remove and add this again:

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

    Then clean and build the project.

    0 讨论(0)
  • 2021-02-19 02:44

    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>
    
    0 讨论(0)
提交回复
热议问题