Error: Apostrophe not preceded by \ (in and failed to execute aapt
Error: Apostrophe not preceded by \ (in and failed to execute aapt
我正在使用 IntelliJ 创建一个 Android 应用程序,并且在重新启动程序时。
我收到此错误:
我还有其他问题:"Cannot resolve symbol R"
The King's Businers 中有一个撇号,只需使用 King\'s Businers
即可。
因为 apostrophe '
是 Android 资源文件中的一个特殊字符,用于标记字符串的开头或结尾。它的所有实例 作为标点符号 必须用反斜杠 \
转义。这样 apostrophe 就可以被解析为文字字符,而不是字符串的 start/end。例如,您有未转义的单词 King's
,这需要变为 King\'s
.
至于 Cannot resolve symbol R
,你能 post 相关的代码吗?您可以尝试通过将克拉移动到红色 R
、按 Alt + Enter
并选择 导入 Class.
来修复它
换行符 (\n) 可能会弄乱您的文本。尝试将内容包装在 CDATA 中:
<string name="the_text">
<![CDATA[
A ton of text \n with the line down char
]]>
</string>
我正在使用 IntelliJ 创建一个 Android 应用程序,并且在重新启动程序时。
我收到此错误:
我还有其他问题:"Cannot resolve symbol R"
The King's Businers 中有一个撇号,只需使用 King\'s Businers
即可。
因为 apostrophe '
是 Android 资源文件中的一个特殊字符,用于标记字符串的开头或结尾。它的所有实例 作为标点符号 必须用反斜杠 \
转义。这样 apostrophe 就可以被解析为文字字符,而不是字符串的 start/end。例如,您有未转义的单词 King's
,这需要变为 King\'s
.
至于 Cannot resolve symbol R
,你能 post 相关的代码吗?您可以尝试通过将克拉移动到红色 R
、按 Alt + Enter
并选择 导入 Class.
换行符 (\n) 可能会弄乱您的文本。尝试将内容包装在 CDATA 中:
<string name="the_text">
<![CDATA[
A ton of text \n with the line down char
]]>
</string>