编辑资源文件时,Android项目将无法生成 [英] Android project won't build when editing a resource file

查看:110
本文介绍了编辑资源文件时,Android项目将无法生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中的Andr​​oid 1.5的项目,每当我只是有一个XML资源文件打开构建死一个错误。例如。如果我有水库\布局\ main.xml中开放的活动文档也不会建立并引发以下错误:

I have an Android 1.5 project in Eclipse and whenever I merely have an xml resource file open the build dies with an error. E.g. if I have the res\layout\main.xml open as the active document it won't build and throws the following error:

Error in an XML file: aborting build.
res\layout\main.xml:0: ERROR Resource entry main is already defined.

然后,我不得不删除 main.out.xml 键,切换到项目中的任何.java文件得到它来构建。

Then I have to delete main.out.xml and switch to any .java file in the project to get it to build.

难道我有什么配置不正确,或者这只是一个Eclipse或ADT错误? 它驱使我坚果了一个小时之前,我找出原因了。

Do I have something configured incorrectly or is this just an Eclipse or ADT bug? It drove me nuts for an hour before I figure out what the cause was.

推荐答案

我碰到了这一点。

如果您有一个XML文件打开,然后点击运行按钮,然后,而不是运行你的Andr​​oid项目Eclipse将尝试运行在XML文件转换。然后,它创建的转换输出一个新的XML文件,并把它添加到您的项目。然后,该项目将无法在所有因为重复的XML文件是否存在运行。

If you have an xml file open and click the 'Run' button, then instead of running your Android project Eclipse will try to run a transform on the xml file. It then creates a new xml file with the output of the transform and adds it to your project. Then the project will fail to run at all because of the existence of the duplicate xml file.

因此​​,请确保你没有任何重复的XML文件在您的项目(看清单文件,以及布局文件)。我解决这个问题的方法是,确保项目树有点击运行前集中(或只需选择与Java文件选项卡)。

So make sure you don't have any duplicate xml files in your project (look at the manifest file, as well as layout files). The way I work around this is to make sure the project tree has focus (or just select a tab with a java file) before clicking 'Run'.

有可能是一个更好的方法(通过配置的变化也许)来处理这个问题,但我pretty的新的Eclipse,这就是我想出了:)解决方法。希望有所帮助。

There is likely a better way to handle this (via a config change perhaps), but I'm pretty new to Eclipse and that's the workaround I came up with :). Hope that helps.

这篇关于编辑资源文件时,Android项目将无法生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆