androidandroid-layout

Android Studio error not well-formed (invalid token)


I am making a app that has a web-app shop for my parents store. When I made a navigation drawer(as far as I know it is correct) but it is giving me an error: AAPT: error: not well-formed (invalid token) but as far as I know, I typed everything correct and did not use wrong tokens. The full error is: AndroidStudioProjects\Pws\app\src\main\res\layout\activity_main.xml:19: AAPT: error: not well-formed (invalid token).

    <LinearLayout

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"

    <include
    layout="@layout/main_toolbar"/>


<RelativeLayout
    android:layout_width="300dp"
    android:layout_height="match_parent"
    android:background="@color/achtergrond">

The error should be around the <include ..... but I cant think of the problem here. What different token should I be using? Or what am I doing wron?

Thanks for reading, I hope some of you could help me out.


Solution

  • You forgot to close the LinearLayout tag.

    It should either be like this:

        <LinearLayout
    
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" />
    
        <include
        layout="@layout/main_toolbar"/>
    

    or like this:

        <LinearLayout
    
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <include
        layout="@layout/main_toolbar"/>
    
        </LinearLayout>
    

    depending on what you're trying to achieve