Sunday, August 22, 2010

Running a Tutorial Wrong

I move on to the first of the view tutorials, Linear Layout.  The tutorial is dead simple, but when I run it, things go nuts.  I get these errors in the console in Eclipse:
[2010-08-18 02:27:04 - HLL] Error in an XML file: aborting build.
[2010-08-18 02:27:04 - HLL] res/layout/main.xml:0: error: Resource entry main is already defined.
[2010-08-18 02:27:04 - HLL] res/layout/main.out.xml:0: Originally defined here.
[2010-08-18 02:27:04 - HLL] /Users/zaradaqaw/Documents/Development/EclipseWorkspaces/AndroidPlay/HLL/res/layout/main.out.xml:1: error: Error parsing XML: no element found
Say what?  There was no main.out.xml file before I ran it.  Eclipse created that empty file and then complains about it?  And somehow this empty file has already defined something so that the real file, main.xml, gets an error?  The error messages are totally unhelpful.  The Problems pane down at the bottom is no help either.

I try deleting the bogus main.out.xml file and trying again, but same result.  After much thrashing and swearing I finally figured it out.  I had gotten used to just doing a Run on the previous tutorial as I modified it and built it several times.  So when it came time to run this new project, I did the same thing.  (It's command-shift-F11 on my Mac.)  When I didn't do was to run it the first time with Run As Android Application, so that Eclipse would know how to run it for this time and all future runs.  You'd think that creating it as an Android Project would have given Eclipse a clue, but nope.  It tried to run my main.xml file instead.

No comments:

Post a Comment