Sweekly Apps

Apostrophes, quotes, @ and ? in Android strings.xml

"Don't" is enough to break an Android build: an unescaped apostrophe in strings.xml is one of the most common Android build errors. The rules are short, and they are all on one page of Android's documentation. Here they are, with the cases translators hit most.

The escape table

CharacterWrite it asNote
' apostrophe\'or put the whole string in double quotes: "Don't stop"
" double quote\""surrounding the string with single quotes does not work"
@\@at the start of a string
?\?at the start of a string
new line\na line break in the file is not kept
< and &&lt; and &amp;the standard XML escaping rules apply

Source: String resources, Android Developers, checked 12 November 2026. The same page notes that "by default Android will collapse sequences of whitespace characters into a single space": wrap the string in double quotes to keep double spaces.

Translations break this more often than the source language: French, Italian and Catalan use the apostrophe constantly, and a translator working in a spreadsheet or a tool doesn't see the XML. Escape at export time, not by hand in each language.

Format arguments

Use numbered arguments, so a language can change the word order:

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>

Every translation must keep the same arguments with the same types: a %1$s that became %1$d, or a missing %2$d, is usually found only when the app runs.

Plurals

Use <plurals>, not one string per count. "The full set supported by Android is zero, one, two, few, many, and other", and Android advises you "always supply "one" and "other" strings". Languages differ in which forms they need.

Where each language goes

The default strings live in res/values/strings.xml; each translation in its own folder, such as res/values-pl/strings.xml. The name attribute is the resource ID, so it must be the same in every file.

A checklist before each release

  1. No unescaped ' or " in any language.
  2. No string starting with a bare @ or ?.
  3. The same format arguments, with the same types, in every language.
  4. one and other present in every plural.
  5. Every key in the default file present in each translation, or knowingly left to fall back.

Keep the strings in a sheet

i18n String Catalog is a Google Sheets add-on that keeps one row per key and one column per language, and exports Android strings.xml with apostrophes, quotes, new lines and a leading @ or ? escaped for you, each language in its own values folder. It also checks placeholders that differ from the source text, and imports and exports JSON, Flutter ARB and Apple String Catalogs (.xcstrings). The free plan covers 300 keys and 2 languages. For a command-line version, see our free open-source exporter.

i18n String Catalog, by Sweekly Apps LLC