[Solved] Android Error: AAPT: error: unescaped apostrophe in string;Multiple substitutions specified in non-positi

I. AAPT: error: unescaped apostrophe in string </ font>

Cause analysis of error reporting

When doing the internationalization multilingual function, I defined some strings in the arrays.xml file as follows

<item>My name's Lisa</item>

The error report is translated as the apostrophe
that is not replaced by the string. Therefore, I thought that the error report may be caused by ', so I replaced the above code with the following code to solve the error report.

<item>My name&quot;s Lisa</item>

Error reporting solution

apostrophe ' available & amp; quot; replacement, such as: <item> My name& quot; s Lisa you can use double quotation marks to enclose string resources, such as: <item>" My name's Lisa" escape characters can be used before apostrophe ', such as: <item> My name\'s Lisa

II. Multiple substitutions specified in non positive format

Cause analysis of error reporting

First, I defined some strings in the string. XML file

<string name = "upgrade_time"> Driver board: %s\t\t signal version.%s</string>

Error reporting translates to multiple substitutions specified in a non location format. The error reporting prompt mentions setting formatted = "false" , so I change the above code to the following one, so I won’t run error reporting.

<string name = "upgrade_time" formatted="false"> Driver board: %s\t\t signal version.%s</string>

Error resolution
After reviewing some blog posts and trying it out myself, there are these ways to fix the above error.
Add formatted="false" attribute in the string with %% to indicate a %
Third, some common HTML special character encoding
In the Android xml file, involving some special characters may be reported in the display of the error, you need to use HTML special characters to convert.

Special symbols HTML encoding
& &amp;
> &gt;
< &lt;
> &gt;
&quot;
> &gt;
Half a blank space ensp;
A blank space &emsp;
> &gt;


Read More: