簡體   English   中英

錯誤解析XML; 格式不正確(令牌無效)

[英]Error Parsing XML; not well formed (invalid token)

我遇到3個錯誤:

錯誤:(8,25)未找到與給定名稱匹配的資源(在“背景”處,值為“ @ mipmap / bg”)。

錯誤:(1)解析XML時出錯:格式不正確(無效的令牌)

錯誤:任務':app:processDebugResources'的執行失敗。

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:處理'command'C:\\ Users \\ George \\ AppData \\ Local \\ Android \\ sdk \\ build-tools \\ 22.0.1 \\ aapt .exe''以非零退出值1結束

我不知道如何解決這些問題,有什么想法嗎? :(

activity_main.xml->

<RelativeLayout 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" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
android:focusable="true"
android:background="@mipmap/bg"
android:clickable="true"
android:backgroundTintMode="screen">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/ClassesOffered"
    android:id="@+id/button"
    android:background="#ff50617c"
    android:ellipsize="middle"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:onClick="getMe"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/StaffButton"
    android:id="@+id/button2"
    android:background="#ff50617c"
    android:ellipsize="middle"
    android:layout_alignTop="@+id/button"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:layout_alignParentTop="true"
    android:layout_alignRight="@+id/button2"
    android:layout_alignEnd="@+id/button2"
    android:background="@mipmap/iklogo" />

</RelativeLayout>

當出現此類錯誤時,建議您始終使用以下方法:刪除部分代碼,然后查看錯誤是否仍然存在。 例如,由於您懷疑android:background="@mipmap/iklogo" ,因此從您刪除整個<ImageView .... />開始。 完全確定-重建/清理項目。 如果問題仍然存在,請刪除下一個標簽。 如果您發現帶有錯誤的標簽,現在可以優化搜索並刪除一些參數行(例如android:background="@mipmap/iklogo" )。 這樣您就可以快速找到問題的根源。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM