android sdk main.out.xml parsing error?

2019-01-10 07:59发布

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

17条回答
叼着烟拽天下
2楼-- · 2019-01-10 08:28

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 :-)

查看更多
放我归山
3楼-- · 2019-01-10 08:29

I believe I have the answer. 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.

Cheers

查看更多
Summer. ? 凉城
4楼-- · 2019-01-10 08:30

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

查看更多
Fickle 薄情
5楼-- · 2019-01-10 08:33

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

查看更多
Fickle 薄情
6楼-- · 2019-01-10 08:33

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.

查看更多
Bombasti
7楼-- · 2019-01-10 08:33

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

查看更多
登录 后发表回答