Search code examples
androidxmleclipseadt

Eclipse ADT - Error parsing XML: not well-formed (invalid token)


I have an array of 9 buttons, in 3 sets of 3. The sets formed by a Horizontal Linear Layout, and the 3 sets come together to form the array of 9 buttons in a parent Vertical Linear Layout.

The error appears at the first button opening tag, and says "Error parsing XML: not well-formed (invalid token)".

I think the problem might be in the opening and closing tags for the LinearLayout, but I've checked multiple times to make sure that they are correct, and I'm pretty sure that they are. I'm not sure what else could be causing the problem.

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

<LinearLayout
    android:id="@+id/layoutVerticalgame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="25dp"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/layoutHorizontalGame1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        <Button
            android:id="@+id/button1"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button2"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button3"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" /> 
    </LinearLayout>

    <LinearLayout
        android:id="@+id/layoutHorizontalGame2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        <Button
            android:id="@+id/button4"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button5"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button6"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/layoutHorizontalGame3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        <Button
            android:id="@+id/button7"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button8"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />

        <Button
            android:id="@+id/button9"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:text="@string/Blank" />
    </LinearLayout>

</LinearLayout>

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/layoutVerticalgame"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="14dp"
    android:text="@string/turn"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
    android:id="@+id/txtPlayerTurn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_centerHorizontal="true"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
    android:id="@+id/button_reset"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtPlayerTurn"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="14dp"
    android:text="@string/reset" />

</RelativeLayout>

Solution

  • It means there is a compilation error in your XML file.

    In your case you have forgotten to close some LinearLayout tags with ">"

    For instance :

    <LinearLayout
            android:id="@+id/layoutHorizontalGame2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
    

    Should be :

    <LinearLayout
            android:id="@+id/layoutHorizontalGame2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">