Android Studio 解析 XML 时出错:格式不正确(令牌无效)



有人可以检查我的.xml,看看是否有任何问题吗?我确信这一直在我的桌面设置上工作,但不适用于我的笔记本电脑。

Error parsing XML: not well-formed (invalid token)
Message{kind=ERROR, text=Error parsing XML: not well-formed (invalid token), sources=[/home/adam/6300Summer18Team67/GroupProject/SDPCryptogram/app/src/main/res/layout/solve_cryptogram_activity.xml:12], original message=, tool name=Optional.of(AAPT)}

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save & Submit"
tools:layout_editor_absoluteX="121dp"
tools:layout_editor_absoluteY="426dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Puzzle #"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="52dp" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="In Progress..."
tools:layout_editor_absoluteX="121dp"
tools:layout_editor_absoluteY="88dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/numAttempts"
tools:layout_editor_absoluteX="74dp"
tools:layout_editor_absoluteY="122dp" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="incorrect submissions"
android:textAlignment="center"
tools:layout_editor_absoluteX="111dp"
tools:layout_editor_absoluteY="134dp" />
<EditText
android:id="@+id/editText3"
android:layout_width="29dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:text="@string/cryptogramId"
tools:layout_editor_absoluteX="163dp"
tools:layout_editor_absoluteY="35dp" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cryptogram"
tools:layout_editor_absoluteX="48dp"
tools:layout_editor_absoluteY="217dp" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Substitution"
tools:layout_editor_absoluteX="48dp"
tools:layout_editor_absoluteY="274dp" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Decryption Preview"
tools:layout_editor_absoluteX="48dp"
tools:layout_editor_absoluteY="339dp" />
<TextView
android:id="@+id/textView7"
android:layout_width="212dp"
android:layout_height="34dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="18sp"
android:typeface="normal"
tools:layout_editor_absoluteX="141dp"
tools:layout_editor_absoluteY="217dp"
tools:text="@string/cryptogram" />
<EditText
android:id="@+id/editText5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:singleLine="true"
android:text="Name"
tools:layout_editor_absoluteX="141dp"
tools:layout_editor_absoluteY="265dp" />
</android.support.constraint.ConstraintLayout>

它是第 12 行字符串中的"&"符号。您可以删除它以验证这一点。

解决方案(这里(是使用&amp;而不是&

android:text="Save &amp; Submit"

或使用 Unicodeu0026字符

android:text="Save u0026 Submit"

符号有时会创建错误事件,尽管它不会在其下方产生那些波浪形的红线。 尝试一次删除一个文本视图上的符号,看看哪个会产生错误。

最新更新