Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
185 views
in Technique[技术] by (71.8m points)

java - Android project won't build when editing a resource file

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 reslayoutmain.xml open as the active document it won't build and throws the following error:

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

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I ran into this as well.

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.

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'.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...