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