阅读237 返回首页    go 阿里云 go 技术社区[云栖]


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

  上一篇:go API Demos 2.3 学习笔记 (10)-- Views->WebView
  下一篇:go c、c++、java的区别