Error in an XML file: aborting build

486 views Asked by At

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" />

2

There are 2 answers

3
JpCrow On

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>
0
Rathan Kumar On

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 >