views:

5638

answers:

11

I just started a new Android project, "WeekendStudy" to continue learning Android development and I got stumped compiling the default 'hello weekendstudy' compile / run. I think that I missed a step in configuration and setup, but I am at a loss to find out where. I have an AVD configured, set and launched.

When I press 'run', the SDK is building a file main.out.xml and then fails as this:

[2010-03-06 09:46:47 - WeekendStudy]Error in an XML file: aborting build.
[2010-03-06 09:46:48 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined.
[2010-03-06 09:46:48 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here.
[2010-03-06 09:46:48 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found
[2010-03-06 09:48:16 - WeekendStudy]Error in an XML file: aborting build.
[2010-03-06 09:48:16 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined.
[2010-03-06 09:48:16 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here.
[2010-03-06 09:48:16 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found
[2010-03-06 09:55:29 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined.
[2010-03-06 09:55:29 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here.
[2010-03-06 09:55:29 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found
[2010-03-06 09:55:49 - WeekendStudy]Error in an XML file: aborting build.
[2010-03-06 09:55:49 - WeekendStudy]res/layout/main.xml:0: error: Resource entry main is already defined.
[2010-03-06 09:55:49 - WeekendStudy]res/layout/main.out.xml:0: Originally defined here.
[2010-03-06 09:55:49 - WeekendStudy]/Users/mobibob/Projects/workspace-weekend/WeekendStudy/res/layout/main.out.xml:1: error: Error parsing XML: no element found
+2  A: 

I was trying to run from the wrong part of the project since my toolbar was not hooked up correctly. I am still working out the details and I will edit this when I figure it out completely.

First of all, this was a new workspace that I wanted to create to organize my different unrelated projects. As a result, the RUN of the toolbar did not have a target configured (i.e., in the history), so it tried to run my main.xml file.

Right-click on one of the *.java files and select 'run as...' then you can create a run configuration with its target (pick or create an AVD), the project, etc. I recommend visiting each of the tabs and review the defaults for your situation.

Then, sit back and wait for the emulator to load for the first time (mine took about 1 to 2 minutes on a Macbook).

mobibob
A: 

reply to floor 1: i have the same problem,although i have created an AVD! 我也有相同的问题,我已经新建了AVD了,问题仍然存在!囧~

learner
+2  A: 

you should run the project as android application not only cilck the icon--Run

wang
Hi Wang, I think you are reporting what was already discovered. I think it is interesting that Eclipse will pretty much let you run anything and the most recent thing I was accessing was a layout-xml file. As a result, the default 'debug' on the toolbar tried to 'debug' my xml. It is a bit silly to be such a literal tool. Thanks for adding your remark.
mobibob
A: 

I have the exact same problem. Can someone help get through this? I am new to eclipse and new to java programming so I really don't understand all the target configuration stuff.
I would greatly appreciate your help man!!!

Neil

neil patel
Hi Neil, It sounds like you are probably new to Eclipse. I did the same remedy the first two times I ran into this problem, then I posted this question. Meanwhile, I have discovered that the solution is as simple as deleting the attempt to 'launch / debug' an XML file as if it were a runtime application. Then be careful to select the project (from the navigation) and right-click 'run as ...' -> android app. You can use the toolbar, but select its drop-down until you are certain that your last run is its current default. This will all be clear when you get more Eclipse experience.
mobibob
A: 

@neil patel > Just restating the answer above ... let me know if it needs to be clarified.

Right-click on one of the *.java files and select 'run as...' then you can create a run configuration with its target (pick or create an AVD), the project, etc. I recommend visiting each of the tabs and review the defaults for your situation.

mobibob
A: 

Is there a way ot to get the build path eror fixed, adding/removing a libraby gets to be a bit of pain as you know as you develop some App it has to be run a few times.

becker666
That is a new question. BTW - I don't think this is an Eclipse error, but a user error instead.
mobibob
If you could shed some light it'd be great. If I do a 'Clean' and then a 'Build All' more than likely I'd get a build path error and the trick of adding/deleting a dummy library solves it but I thought perhaps there is a more elegant way to handle this.
becker666
@becker666 sorry I did not notice your second comment. Can you please open a new question. This is unrelated to the original posted question.
mobibob
A: 

Deleted the xxx.out.xml, if still can't run, please follow this Eclipse ->Project->Clean...->Choose your project->OK

Set the cursor in your *.java, Run it

A: 

I had the same problem and tried alot of different things. Finally I gave up, copied the entire project tree to another location. Created a new Android project and copied the src files, res.layout, res.values files and my added custom images under drawable. Right clicked the project in package explorer and hit "Refresh". Now it works again. Probably not the best way to fix it but it works :-)

Weke
see my comment to @zohar above.
mobibob
A: 

I had the same problem as wall , my solution was :

Just import it again without creating new project

first try do do that:

Eclipse ->Project->Clean...->Choose your project->OK

If that didn't work, try this..

1.copy the project folder from workspace to some where else (desktop will be fine) 2.delete project from eclipse (checked the box "delete Project content from disc" ) 3.copy the project again just this time from desktop to workspace 3.import the project again (File>>Import>>General>> Existing project into workspace ) 4.that's worked for me ..

hope it helped

http://www.wave-site.com/

Zohar Adar
@zohar - that is a lot of unnecessary file moving. Eclipse is a bit obtuse for some activities, but all that is needed is to delete the accidentally "compiled" xml file. If you have a file foo.out.xml suddenly show up in your project, chances are that you tried to 'run' while the selection was on the file foo.xml. Just delete foo.out.xml, refresh your project and compile it correctly. In the future, be careful to not 'run' or 'run as...' while selecting a resource file.
mobibob
Thanks @mobibob you right, I tried to do that, but it seems that the foo.out.xml stuck in the memory and i kept get the massage error about the foo.out.xml although the file deleted from disk.do you familiar with that?
Zohar Adar
@zohar - honestly, it is not in memory. When that happens to me is when I press the "run icon" without realizing that my selection/focus is on an XML file. I do this (accidentally) when I edit my manifest and then click without using the drop-down feature or hover. It then creates the file and I delete it immediately. *THEN* I try to stick to *ALWAYS* using the drop-down of the toolbar button for running my code. Make sense?? In other words, it is just careless user error when trying to work too quickly.
mobibob
A: 

This appears to be an issue with one of eclipse's XML plugins, I think it is something in Web Tools. I used to be able to run the app from any file, be it XML or java, but once I installed Web Tools I started seeing this error. It really is annoying, I am so used to pressing Ctrl-F11 to build the app...but if you do that in an XML file you get this error. The fix mentioned above does work, but it is extra steps and less efficient to have to right-click the project and select Run As... blah blah. If anyone figures out a clean solution - besides removing Web Tools of course - to get me back my shortcut key I would be grateful.

estitt
A: 

Yeah, same problem with me.

To prevent out.xml from being created.

  1. edit an XML file, a perfectly natural thing to do....

  2. save and close the XML file

  3. Open any .java file in src/

  4. Double click in the file to ensure it has focus and the cursor is in there.

  5. Run... should be OK now

If it happens, do this...

  1. edit an XML file, a perfectly natural thing to do....

  2. Run... crash due to dreaded out.xml file

  3. Delete the /res/_.out.xml file

  4. Close all files in the IDE view

  5. Project...Clean...

  6. Open any .java file in src/

  7. Double click in the file so it has focus and the cursor is in there.

  8. Run... should be OK now

Berry Wing