撇号前面没有 \\

Apostrophe not preceded by \\

我有这样一个字符串资源值:

<string name="you_sure">Are you sure you want to do this?\n(It can't be recovered.)</string>

构建我的 android 项目时,我不断收到错误消息:

Error:(377) Apostrophe not preceded by \ (in Are you sure you want to do this?\n(It can't be recovered.))

为什么?

因为你有一个撇号("can't" 中的 '),这些需要转义为 \'。引号 (\").

也是如此

刚刚阅读manual

两者都

This\'ll work

"This'll work"

正确

你不需要转义'\n'