Android 編譯錯誤——布局 Error parsing XML: not well-formed (invalid token)
阿新 • • 發佈:2017-06-06
XML width 文件 format source 註意 for 編碼 invalid
在修改了Android布局文件後,編譯出現Error parsing XML: not well-formed (invalid token)。
首先先排查xml文件的編碼格式是否為UTF-8, <?xml version="1.0" encoding="utf-8"?> ,註意,從別處copy的要留意編碼格式!
還有各個標簽是否有遺漏,把鼠標箭頭移到出錯誤的layout上 點擊鼠標右鍵選擇Source然後再選Format。
都沒有問題,結果發現報錯處(第9行):
1 <TextView 2 3 android:id="@+id/TetxView1" 45 android:layout_width="wrap_content" 6 7 android:layout_height=“wrap_content” 8 9 android:text=">31" 10 11 android:textSize="@dimen/text_size" 12 13 android:textColor="@color/text_color" 14 15 />
在控件屬性值裏包含“>”或“<”,就會出錯,建議在代碼中賦值!
Android 編譯錯誤——布局 Error parsing XML: not well-formed (invalid token)