55

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
mobibob
  • 8,670
  • 20
  • 82
  • 131
  • 1
    I think I have the answer. I am not running the correct source. I found a hint at this web forum. http://www.anddev.org/viewtopic.php?p=31088 – mobibob Mar 06 '10 at 16:23
  • There is a related bug report against Eclipse here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=287951. The resolution seems to be "not my problem". – Mu Mind Jul 08 '11 at 15:44
  • The bug report gave a solution that worked for me: Help -> Install new software -> already installed -> XSL Tools -> uninstall – Thomas Rebele Nov 30 '17 at 17:59

16 Answers16

94

Better fixing: Eclipse -> Window -> Preferences -> Run/Debug -> Launching -> Lauch Configuration

Cross : Filter checked launch configuration types and Cross also : XSL (at the end of the list)

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • I did not have the XSL in my list. The only items that were listed (all unchecked) where runnable units (e.g., application, junit, android, etc.) -- so is this a list of exclusion of inclusion? BTW - +1 for this answer as this is the type of configuration setting that I was hoping to hear about. – mobibob Mar 31 '11 at 19:38
  • @mobibob: are you sure you went to window->preferences->run/debug->launching->launch configurations, or did you just open run configurations under ->run? They are different places – Thomas Dignan May 09 '11 at 03:38
  • @Tom Dignan - I eventually found the correct config dialog. On the Mac the preferences that you are referring to is under Eclipse -> Preferences -> Run/Debug -> Launching -> Launch Configuration. – mobibob May 09 '11 at 04:29
  • 5
    This seems like a step in the right direction, but my installation of Eclipse (Helios) _still_ launches these as XSL Transformations when I click the "Run" button, even though XSL isn't in the "Run Configurations" list anymore. After it launches, it adds "XSL Transformation" to the "Run As" entry in the context menu. – Mu Mind Jul 08 '11 at 15:40
  • 8
    I'm in the same boat as Mu Mind, but with Eclipse (Indigo). So I then found this to help, set the run button to always launch the previous operation: Eclipse -> Window -> Preferences -> Run/Debug -> Launching -> Launch Operation -> Always Launch the previously launched application – DonnaLea Aug 22 '11 at 05:26
  • +1 I have no idea what this does but it worked for me. Thanks! – Leo Oct 07 '11 at 18:43
  • Same problem as Mu Mind. I was trying to remove XSL plugin first, but I could only remove entire Java EE environment. (actually I did remove them, then Eclipse itself was gone...) I download and reinstall Eclipse Classic 3.7.1 and ADT plugin, then it works peacefully. – Nobu Nov 26 '11 at 22:08
  • Followed DonnaLea's instructions as well as OP and it works for me on Eclipse Indigo with a CTRL+F11 while editing an XML file. – dcompiled Mar 10 '12 at 20:05
  • i hope that eclipse or adt developers make this problem go away so we don't have to... so annoying. – botbot Apr 27 '12 at 01:04
27

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
  • 271
  • 3
  • 2
11

You should run the project as android application not only click the icon--Run

Nimantha
  • 6,405
  • 6
  • 28
  • 69
wang
  • 111
  • 2
  • 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 Apr 19 '10 at 03:14
  • This is exactly what has happened to me! Thanks! The solution from accepted answer did not mention what was happening even though they say how to get rid of "launching" main.xml in the future which was the problem here. – inkredibl Jun 15 '11 at 08:30
8

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

user383343
  • 801
  • 1
  • 7
  • 8
  • 1
    I really Dont know how old this Q is , but lot of answers above told how to correctly launch it , but this tells how to FIX it , +1 from my side :) – GoodSp33d Dec 12 '10 at 14:20
5

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
  • 8,670
  • 20
  • 82
  • 131
2

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
  • 29
  • 1
1

I encountered this problem too and got frustrated. Uninstall whole Android SDK and reinstall, thinking in mind that there was some problem.

To my surprise, solution is very simple. If you leave the mouse click over xml file and go to Run it will generate error. So the solution is simple. Click on .java file or Top of the whole tree (example: if the structure is like this: Firstapp>Src>Firstapp.java, just click on Firstapp) and then run.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Anand
  • 11
  • 1
  • 1
    sorry you ran into it too :( It is extremely common and easy to bump into, however, your solution probably worked because you reinstalled SDK and probably had a new project. However, if you ever make the mistake and generate any *.xml.out file, your project will not clean, run, etc. until you explicitly delete the rogue file. I recommend you follow the advice above from, @Hugo Garcia-Cotte, that will prevent Eclipse from trying to inadvertently run any XML file. – mobibob May 12 '11 at 17:13
0

When using eclispe make sure before clicking "Run", Any file selected in Project is not the XML file.With this you will never get this error. Also, Make sure you have deleted all the ....out.xml from your workspace.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jha
  • 107
  • 4
  • 11
0

I faced this problem but above answers do not help me. After look around, I fixed this by my self and I think I should write down the solution.

The android compiler create *.out.xml if you run the project as XSL. to fix this, you should do these steps:

  • click on the arrow at right side of Run button, select Run Configurations. At the left side of popup windows, delete all sub-items under XSL.
  • go to Launch configuration under preferences=>Run/debug =>Launching. Check to "Filter checked launch..." and then, uncheck XSL when keeping check on Android Application.
Nimantha
  • 6,405
  • 6
  • 28
  • 69
Nguyen Minh Binh
  • 23,891
  • 30
  • 115
  • 165
0

As stated in How to stop Eclipse from trying to run XML files?: Under Preferences -> Run/Debug -> Launching, you can select "Always launch the previously launched application". This is useful if you tend to use the Ctrl+F11 shortcut.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
pypmannetjies
  • 25,734
  • 7
  • 39
  • 49
0

@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
  • 8,670
  • 20
  • 82
  • 131
0

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
  • 1
0

I too was able to run with just any ol' file selected. Something changed and suddenly I was getting the dreaded xxx.out.xml parse error. Well, I found a way around it. Someone please confirm for me that this works for you too.

Click Window->Preferences Select or filter search for Launching(run/debug)

In the bottom of the right hand pane, look for Lauch Operation and select "Always launch the previously launched application"

Clean your project and run it correctly at least once. I tested this out and it seems to work consistently.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
R Hughes
  • 640
  • 9
  • 22
0

Do try, and check the valid source is running or not.

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

user366584
  • 1,016
  • 1
  • 16
  • 34
-1

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

Nimantha
  • 6,405
  • 6
  • 28
  • 69
ZoharAdar
  • 474
  • 1
  • 7
  • 19
  • 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 Aug 12 '10 at 15:45
  • 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? – ZoharAdar Aug 15 '10 at 11:14
  • 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 Sep 02 '10 at 20:11
-1

Eclipse ->Project->Clean...restart your project ,and that's ok

  • 1
    The reason that appears to work is that when you return back to Eclipse, your focus is not on the XML file of the navigation panel. This isn't a very good solution if one had to always clean and restart. Simply delete the rogue file and be careful to not create it again. Know where your focus is before "running" from Eclipse. (See accepted answer above and its discussion.) – mobibob Dec 23 '10 at 13:17