现在的位置: 首页 > 综合 > 正文

Eclipse中编译Android项目工程失败,提示: Error in an XML file: aborting build 解决办法

2013年06月13日 ⁄ 综合 ⁄ 共 963字 ⁄ 字号 评论关闭

问题:

在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或者其他的资源文件。或者直接通过菜单来编译或者调试。

抱歉!评论已关闭.