0

I face an error in my main.xml. It display the error: "error parsing xml unbound prefix" at

My code 
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/white"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >

<com.facebook.android.LoginButton
        android:id="@+id/login"
        android:src="@drawable/login_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_margin="30dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"/>

Error here--> />

    <Button android:id="@+id/infoButton"
        android:text="@string/information"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_below="@+id/txt"
        android:layout_alignRight="@+id/txt"
        />

    <Button android:id="@+id/postButton" 
        android:text="@string/post"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_below="@+id/txt"
        android:layout_alignLeft="@+id/txt"
        />

    <Button android:id="@+id/friendButton" 
        android:text="@string/friend"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_below="@+id/postButton"
        android:layout_alignLeft="@+id/postButton"
   />
   <ListView  
        android:id="@+id/friendsview"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:textFilterEnabled="true"
        android:layout_below="@+id/friendButton"
        android:layout_centerHorizontal="true"
    />

</RelativeLayout>

and in my java files, it display error at the everything relating to R. For example: R.layout.main

Could you please help me? Thank you so much.

lovesunset21
  • 11
  • 1
  • 3
  • It may help you:- http://stackoverflow.com/questions/15679466/error-parsing-xml-unbound-prefix-with-the-facebook-sdk – pRaNaY Jan 29 '15 at 05:39

2 Answers2

1

I believe the xmnls attribute should be the first attribute you declare in your RelativeLayout, otherwise it doesn't know what to do with the android: prefixes.

dmon
  • 30,048
  • 8
  • 87
  • 96
  • I tested that theory, as longs as its in the RelativeLayout it doesn't have to the first one, you can put it anywhere in the RelativeLayout. – n4rzul Jun 09 '11 at 09:11
-1

For your first question i.e. "error parsing xml unbound prefix", it could be coming because of the Facebook Login Widget. Try adding Facebook namespace to the RelativeLayout definition. Something like below:

<RelativeLayout 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/white"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:facebook="http://schemas.android.com/apk/res-auto">

For errors related to "R", trying putting an extra import in your activity class

import package.where.activity.is.present.R; 

Hope this helps!

deepak
  • 72
  • 4
  • You are not supposed to add import import package.where.activity.is.present.R; It is automatically generated – Alaa Aug 24 '15 at 20:52