Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:(218) Apostrophe not preceded by \

In my strings.xml, I have made a string containing (it's) and I get this error.

Error:(218) Apostrophe not preceded by \

Yes, I know I have to either place a \ before the apostrophe, or just delete the apostrophe, but my problem is that when I run the app using (it\s) or just deleting it, it comes back; even if I delete the whole string, it all comes back when I click run. How do I stop this?

Here's the String but it really doesn't matter. I just want it to be deleted and not restored when I run the app.

<string> name="talk" So, you want these things? LOL its gonna</string>
like image 817
John Westlen Avatar asked Feb 24 '16 01:02

John Westlen


3 Answers

When the error occurs, Android Studio opens the values.xml which, at that point in the file, deceptively looks exactly the same as your strings.xml. Make sure you're updating the strings.xml and you should be good to go.

like image 189
David Avatar answered Sep 28 '22 03:09

David


Actually, there are two files strings.xml and values.xml

We edit our string data in strings.xml and whenever we getting the error like Apostrophe not preceded by \, When you click on error android studio redirect you to values.xml and you are editing in values.xml and android studio just deleted what you edited.

So make sure you are editing strings.xml not values.xml

like image 41
Puneet Verma Avatar answered Sep 28 '22 04:09

Puneet Verma


Place your string in double quotes.<string>"Your text 'here'"</string>

like image 29
Jeffrey Nyauke Avatar answered Sep 28 '22 04:09

Jeffrey Nyauke