main.xml error

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

main.xml error

Postby momob » Wed Aug 12, 2009 8:18 am

Hello guys,

I just started Android dev and already running into some weird issue. I used Draw Android to build my layout and it worked fine. I did some change to the main.xml and now I am getting the error message below. I tried to do it again (using the Draw Android and past the xml code into main.xml and still get the same error? There is a file called main.out.xml which seems to be empty. I am not sure of its role. I am assuming I did something wrong but here the main.xml code and the error message.

I will love some pointers to check. I am really puzzled since I do not see anything wrong with my xml code?? For instance I do not understand the error seen below: ERROR Resource entry main is already defined.
I only have one main.xml

Thanks guys.

Mo.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget89"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/myText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
>
</TextView>
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
>
</Button>
</LinearLayout>


'//---------------------------------------------------------------- error log on the Console -------------------------------

[2009-08-12 00:07:30 - NumentaVision] Error in an XML file: aborting build.
[2009-08-12 00:07:30 - NumentaVision] res\layout\main.xml:0: ERROR Resource entry main is already defined.
[2009-08-12 00:07:30 - NumentaVision] res\layout\main.out.xml:0: Originally defined here.
[2009-08-12 00:07:30 - NumentaVision] C:\Documents and Settings\Mo\workspace2\NumentaVision\res\layout\main.out.xml:1: ERROR Error parsing XML: no element found
momob
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jul 13, 2009 8:55 pm

Top

Postby s4b3r » Thu Aug 13, 2009 3:00 pm

hi there,
had the same problem and now i found the solution!

Just make sure when you run the application, that you are editing an .java file
and not an .xml file!

and you have to delete "main.out.xml"
User avatar
s4b3r
Freshman
Freshman
 
Posts: 4
Joined: Thu Aug 13, 2009 2:55 pm

Postby momob » Thu Aug 13, 2009 6:45 pm

Hello s4b3r,

WOW! Thanks for taking the time. The strange thing is that it worked today (the app ran) then I tried to edit the main.xml to change the text on a button. When I run the app, the problem came back! It again generated a main.out.xml. When I delete that file, it gets generated again when I try to run the app. It is very frustrating (i am sure you had the same frustration before you figure out the issue) I am very sorry to be slow on this but I am not sure I understand this sentence:

s4b3r wrote:hi there,
Just make sure when you run the application, that you are editing an .java file
and not an .xml file!"


Do you mean to make sure to edit a ".java" type file for the activity and not a ".xml" type file. I am not sure there is a way to make a mistake on this. my activity (only one) has ".java" type and the layout file main has a ".xml" type.

Could you give me (when you get a chance) a little bit more details? Thanks so much again for taking the time.

Take care,

Mo,
momob
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jul 13, 2009 8:55 pm

Postby s4b3r » Thu Aug 13, 2009 7:02 pm

Yeah, took me a while to figure it out.
The solution is that you have to be in the .Java File and have deleted the main.out.xml when you run your application.

I hope i could explain it a bit better this time.
User avatar
s4b3r
Freshman
Freshman
 
Posts: 4
Joined: Thu Aug 13, 2009 2:55 pm

Postby momob » Thu Aug 13, 2009 7:31 pm

IT WORKED!!!!!!!!!!!!!!!!!!!!!!!!!!

i OWE you a beer! I have no idea how you figured out that you needed to be in a ".java" window (ie: the cursor being set in your app XYZactivity.java window and NOT in the layout main.xml window) but you saved tons of headaches! I wouldn't have find a solution in a millions years! That 's is a very odd behavior. It does explain why just editing the layout main.xml last (even so the editing was fine) it brought the problem back since my cursor was still on the main.xml window.

THANK YOU! :D :D :D :D :D :D :D :D

Mo.

ps: Now I can go back having fun learning about Android!
momob
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jul 13, 2009 8:55 pm

Postby kaista » Wed Sep 09, 2009 1:32 am

s4b3r wrote:Yeah, took me a while to figure it out.
The solution is that you have to be in the .Java File and have deleted the main.out.xml when you run your application.

I hope i could explain it a bit better this time.


This would have took ages, I created account on here purely to say thankyou.. very useful.. at first I was confused but realised you actually meant have a .java file open in the editor for it to compile right.. is this a bug in eclipse?
kaista
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Sep 09, 2009 1:27 am

Top

Postby LokisDad » Sun Dec 13, 2009 10:07 pm

kaista wrote:
s4b3r wrote:Yeah, took me a while to figure it out.
The solution is that you have to be in the .Java File and have deleted the main.out.xml when you run your application.

I hope i could explain it a bit better this time.


This would have took ages, I created account on here purely to say thankyou.. very useful.. at first I was confused but realised you actually meant have a .java file open in the editor for it to compile right.. is this a bug in eclipse?


More precisely, it's that you need to run your java app, not your xml file. If the xml file gets to be first on the Run History and you just say Run, you're attempting to run the xml file again, and you get the empty main.out.xml file. Delete it in your package files tree, then use Run -> Run History to make sure you're running your java code.

hth, --emk
LokisDad
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Dec 13, 2009 10:00 pm

Postby faheemsial » Tue May 04, 2010 9:53 am

Hi,i hve same problem n after reading this post i deleted main.out.xml but not used :( any idea?
Faheem Akbar Sial,
Software Engineer,
Pakistan.
faheemsial
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 04, 2010 8:46 am
Location: LHR

Re: main.xml error

Postby grace1981 » Tue May 18, 2010 3:16 pm

Deleted the xxx.out.xml, if still can't run, please follow this
Eclipse ->Project->Clean...->Choose your project->OK
grace1981
Once Poster
Once Poster
 
Posts: 1
Joined: Tue May 18, 2010 3:04 pm

Re: main.xml error

Postby borlor » Wed May 26, 2010 4:19 pm

thanks a bunch .. this post deserves another 1 up !
borlor
Once Poster
Once Poster
 
Posts: 1
Joined: Wed May 26, 2010 4:17 pm

Re: main.xml error

Postby amartiniuc » Sat Jun 05, 2010 10:27 pm

Worked for me as well. Thanks for the posts. They were very useful.
amartiniuc
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 05, 2010 10:25 pm

Re: main.xml error

Postby Slimtech » Tue Jun 22, 2010 5:50 pm

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


Just registered to say thank you! I wish I searched this before rebuilding my whole app. Anyways, it's fixed!

Thank you everyone!!
Slimtech
Freshman
Freshman
 
Posts: 3
Joined: Tue Jun 22, 2010 5:48 pm

Re:

Postby the1johnson » Sat Jun 26, 2010 2:07 am

kaista wrote:
s4b3r wrote:Yeah, took me a while to figure it out.
The solution is that you have to be in the .Java File and have deleted the main.out.xml when you run your application.

I hope i could explain it a bit better this time.


This would have took ages, I created account on here purely to say thankyou.. very useful.. at first I was confused but realised you actually meant have a .java file open in the editor for it to compile right.. is this a bug in eclipse?



Yup same here! thanks a million!
the1johnson
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 26, 2010 2:06 am

Re: main.xml error

Postby hessas_m » Sat Sep 11, 2010 10:24 pm

Merci beaucoup, vous m'avez vraiment aidé, j'ai fermé tous les fichiers .XML, supprimé le out.XML, mais ça n'a pas suffit, il a fallut que je fasse project -> Clean All projects. Et le miracle arrive : tout fonctionne bien.
Il faut avant d'exécuter s'assurer qu'on a la souris sur une classe .java.

Thank's for your help.
hessas_m
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Sep 11, 2010 10:20 pm

Re: main.xml error

Postby moose517 » Sun Sep 12, 2010 5:42 am

i just registered here for the sole purpose for giving much thanks to the person that said to be on the java file and clean solution, i was going mad tryin to figure this error out.
moose517
Freshman
Freshman
 
Posts: 4
Joined: Sun Sep 12, 2010 5:41 am

Top
Next

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests