Guy Richards
Guy Richards

Reputation: 27

Error parsing XML: not well-formed (invalid token) strings.xml (Android SDK / Eclipse)

I have a very simple strings.xml file however I still seem to be getting an error on it (and I have no idea why!)

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Linking Manager</string>
<string name="button1">Linking Manager</string>
</resources>

Any ideas?

Upvotes: 0

Views: 5635

Answers (5)

Attacktive
Attacktive

Reputation: 615

In my case, I have accidently copied Drawable files into res/values, not res/drawable.

For sure, Drawable files are never well-formed XML files... How silly. :s

Upvotes: 0

GreddyDC5
GreddyDC5

Reputation: 21

I had a similar issue because R.java took a crap on me. After I fixed it, I was unable to run the program because of this error. I went into the bottom tab that says "Problems", just before the tab @Javadoc, Declaration, Console, LogCat, and Properties. I saw some errors there and I deleted them. Since the code was fine it was able to run back up.

I had this issue a long time ago, and because I didn't know how to solve it I just created an entire new project. Hopefully this will help someone else down the line.

Upvotes: 0

Noumenon
Noumenon

Reputation: 6412

I have had this error happen because I had a tiny little backtick at the front of the line where the error was. Didn't notice typing it and it was hard to see so far away from the indented lines.

Upvotes: 0

Edward van Raak
Edward van Raak

Reputation: 4910

Make sure there are no spaces before and after

<?xml version="1.0" encoding="utf-8"?>

Also clean project.

If all else fails, delete the XML file and recreate it and paste it back again. It doesn't give any errors when I use it.

Upvotes: 0

Vishal Vijay
Vishal Vijay

Reputation: 2528

In eclipse just open string.xml and then press ctrl+shift+F This will format your source code.

Upvotes: 3

Related Questions