Eclipse中編譯Android項目工程失敗,提示: Error in an XML file: aborting build 解決辦法
問題:
在Eclipse中編寫Android項目代碼時,假設當前激活窗口是某個xml文件,此時,你按鍵Ctrl+F11或者F11,就會生成一個類似*.out.xml的文件,然後在console窗口提示一下錯誤:
[2011-09-24 03:14:54 - HelloWorld] Error in an XML file: aborting build. [2011-09-24 03:14:54 - HelloWorld] res/layout/main.xml:0: error: Resource entry main is already defined. [2011-09-24 03:14:54 - HelloWorld] res/layout/main.out.xml:0: Originally defined here. [2011-09-24 03:14:54 - HelloWorld] /home/snowdream/workspace/git/workspace/android/HelloWorld/res/layout/main.out.xml:1: error: Error parsing XML: no element found [2011-09-24 03:14:56 - HelloWorld] res/layout/main.xml:0: error: Resource entry main is already defined. [2011-09-24 03:14:56 - HelloWorld] res/layout/main.out.xml:0: Originally defined here. [2011-09-24 03:14:56 - HelloWorld] /home/snowdream/workspace/git/workspace/android/HelloWorld/res/layout/main.out.xml:1: error: Error parsing XML: no element found
因為當前激活窗口是某個xml文件時,編譯時,編譯的是這個xml文件,而不是整個android項目工程。
解決辦法:
在編譯或者調試Android項目工程時,如果要用到快捷鍵Ctrl+F11或者F11,確保當前激活窗口是java文件,而不是xml或者其他的資源文件。或者直接通過菜單來編譯或者調試。
最後更新:2017-04-02 06:51:58