Skip to content Skip to sidebar Skip to footer

Apostrophe Not Preceded By \

I have a string defined in an android application: '{string}' occurs {times} This gives the error: Apostrophe not preceded by \ (i

Solution 1:

these should both work according to http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling:

<string name="search_occurs">\'{string}\' occurs {times}</string>
<string name="search_occurs">"'{string}' occurs {times}"</string>

Solution 2:

just put \ before ' in your string It's FALSE It\'s TRUE :)

Solution 3:

Why don't you provide the ' with the string you replace it with?

Also you know constructs like this?

<stringname="profile_age_range_text_between">between %1$d and %2$d</string><stringname="unit_height_inches">%1$d\'%2$d ft</string><stringname="unit_distance_miles">%s mi</string>

Solution 4:

Replace Your apostrophe (') with (\') or add \ before every (')

note: copy only inside () text

Solution 5:

Make sure that you are editing the correct file. As this answer states, when you get the error, Android Studio opens a values.xml file, which looks similar to your original file. You have to add the \ in the original strings.xml file (or wherever the offending character is). Otherwise it will just keep repeating the error.

Post a Comment for "Apostrophe Not Preceded By \"