• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Error parsing Xml. not well formed(invalid token)

Muesum

Lurker
Hi! completely new to development and this forum, just ran into this error when trying to follow a tutorial on youtube. Just tried to search similar topics here but i didnt find any (strangely enough...) so excuse me in advance please for polluting this place :)

Basically all was going OK, yesterday evening, everything worked fine. I saved and put my PC to sleep. So today I wanted to move forward and BAM my eclipse has its first period. Everything is red. So i found out that my R.java file thought that its time to suicide, and it did just that. I Checked my Res folder for weird names, its fine. And i came to conclusion that - ERROR parsing XML - in one of the xml files is the cause of all my problems. (probably appeared after i cleaned my project to get rid of one another error)

since that error is basically a typing mistake, i will post my code here because i must be blind. I dont see it. I have copied and pasted stuff around to make everything clear but that error doesnt disappear, so i probably have missed something. maybe more experienced eyes can detect the problem better.

<RadioGroup
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"

<RadioButton
android:id="@+id/rbNormal"
android:layout_width="wrap_content"
(X) android:layout_height="wrap_content"
android:text="Normal" />
<RadioButton
android:id="@+id/rbItalic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Italic" />
<RadioButton
android:id="@+id/rbBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bold" />

</RadioGroup>


thanks in advance!
 
Hi,

So i just wanted to tell that I went the radical way and deleted the file where supposedy i had error in. Funny thing was, every time i used Project-clean it found the same error on different line of code so finding the source of mistake was pretty much impossible, thus leading to R. java not being created and having other errors aswell...

Error in xml was sometimes paired with <LinearLayout> error saying it must end with </LinearLayout> (this one disappeared and reappeared randomly in different places aswell) or have something in between or something like that. I checked everything there, it should have been OK, especially taking into account the fact that Yesterday that code Definetely worked and everything was great.

So i deleted the file, recreated it and then my R.java came back and i can continue my work... hopefully.

maybe if some higher up sees this, he could move the thread or close it.
 
The one thing I notice is that you don't have a close ">" in your first group of declarations. You typed:

<RadioGroup
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"

<RadioButton

In XML, before declaring a new nested block (in this case, nesting a RadioButton within RadioGroup), you need to close the last statement before RadioButton with a ">". So instead of "android:layout_weight="1"" you should put "android:layout_weight="1" >"

Aside from that, your XML looks well-formed. One thing to note about Android and Eclipse, is that if any of your XML files are ill-formed, Eclipse will not generate R.java. This is probably the reason why you are getting errors everywhere, even if you are changing a few things. R.java is what all your *.java files use to speak with the UI. If it doesn't exist, all its calls to its resources will generate errors (every call it makes passes through R, which doesn't exist).

Hope this helps. I'm just getting started myself and had to wrestle with this one a little bit as well. Good luck!
 
Back
Top Bottom