0

I am new android development. I'm creating a screen with a few buttons but when run it i get the below error. What does this mean and how can I avoid it?

Error in an XML file: aborting build.

the markup in the document following the root element must be well-formed

   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frontpagelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/lg"/>



<Button
    android:id="@+id/uyounadults"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_below="@+id/umusicfan"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="19dp"
    android:text="@string/uyoungadults" />

<Button
    android:id="@+id/umusicfan"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_below="@+id/ushop"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="19dp"
    android:text="@string/umusicfan" />

<Button
    android:id="@+id/utourist"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_below="@+id/ufamily"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="20dp"
    android:text="@string/utourist" />

<Button
    android:id="@+id/ufamily"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_below="@+id/uyounadults"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="26dp"
    android:text="@string/ufamily" />

<Button
    android:id="@+id/ustudent"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_below="@+id/utourist"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="17dp"
    android:text="@string/ustudent" />

<Button
    android:id="@+id/ushop"
    android:layout_width="200dp"
    android:layout_height="40dp"
    android:layout_alignLeft="@+id/umusicfan"
    android:layout_alignParentTop="true"
    android:layout_marginTop="96dp"
    android:text="@string/ushop" />

<TextView
    android:id="@+id/welcome"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="18dp"
    android:layout_marginTop="16dp"
    android:text="@string/welcome"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/selection"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/welcome"
    android:layout_below="@+id/welcome"
    android:layout_marginTop="15dp"
    android:text="@string/selection"
    android:textAppearance="?android:attr/textAppearanceSmall" />

1
  • The RelativeLayout tag isn't closed properly Nov 29, 2014 at 17:00

2 Answers 2

2

You are closing the relative layout there itself you have to close that end of the document like below:

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/frontpagelayout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@drawable/lg">

        <Button
         android:id="@+id/uyounadults"
         android:layout_width="200dp"
         android:layout_height="40dp"
         android:layout_below="@+id/umusicfan"
         android:layout_centerHorizontal="true"
         android:layout_marginTop="19dp"
         android:text="@string/uyoungadults" />


   //You can add another views here

    </RelativeLayout >
0
1

You are missing the first line in the xml:

  <?xml version="1.0" encoding="utf-8"?>
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/frontpagelayout"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@drawable/lg">

       stuff here

       </RelativeLayout>
3
  • im sorry as i said im new to android applications where am i supposed to put that exactly?
    – balcuh
    Nov 29, 2014 at 17:04
  • In the first line of your xml.
    – JpCrow
    Nov 29, 2014 at 17:05
  • okay i have put that line there and it still gives me the same error
    – balcuh
    Nov 29, 2014 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.