[Solved] unescaped apostrophe in string

I have searched alot, but nowhere found the answer/solution for following:

In Android Studio, I hava a project that works without problems for many years. After updating in ‘build.grandle’ file compileSdkVersion to ’28’, buildToolsVersion to ‘28.0.2’ and targetSdkVersion to ’28’, it is not possible to become a clean build due to:

error: unescaped apostrophe in string
Message{kind=ERROR, text=error: unescaped apostrophe in string, sources=[/home/…/app/src/main/res/values/arrays.xml:77:5-89:20], original message=, tool name=Optional.of(AAPT)}

error: could not parse array item.
Message{kind=ERROR, text=error: could not parse array item., sources=[/home/…/app/src/main/res/values/arrays.xml:77:5-89:20], original message=, tool name=Optional.of(AAPT)}

A lot of similar questions exist on the web handling the apostrophe problem, but in my case, there is no apostrophe in ‘arrays.xml:77:5-89:20’:

...
77    <string-array name="textFontSizeValues">
78        <item>0</item>
79        <item>1</item>
80        <item>2</item>
81        <item>3</item>
82        <item>4</item>
83        <item>5</item>
84        <item>6</item>
85        <item>7</item>
86        <item>8</item>
87        <item>9</item>
88        <item>10</item>
89    </string-array>
...

Edit:
Also having only

...
<string-array name="textFontSizeValues">
</string-array>
...

gives the same errors, which does not make sense for me as there is no “apostrophe”

Solution #1:

I suppose you already found the solution but just in case.

I had the same error and found the wrong apostrophe , but in your case is weird as it seems you only have numbers.

I would do the same as i did: Delete all items in the array, check if you don´t get the error and write one by one manually without copy and paste. its a short code so you could manage.

Good luck!

Respondent: Bosancero

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.