首页 > 解决方案 > Android Studio 错误格式不正确(无效令牌)

问题描述

我正在为我的父母商店制作一个具有网络应用商店的应用。当我制作导航抽屉时(据我所知它是正确的)但它给了我一个错误:AAPT:错误:格式不正确(无效令牌)但据我所知,我输入的所有内容都是正确的并且没有使用错误的令牌。完整的错误是: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">

错误应该在 <include ..... 但我想不出这里的问题。我应该使用什么不同的令牌?或者我做错了什么?

感谢您的阅读,我希望你们中的一些人可以帮助我。

标签: androidandroid-layout

解决方案


你忘了关闭LinearLayout标签。

它应该是这样的:

    <LinearLayout

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

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

或像这样:

    <LinearLayout

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

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

    </LinearLayout>

取决于你想要达到的目标


推荐阅读