6

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"

Bosancero
  • 61
  • 1
  • 3
  • 1
    Any chance that you copy-pasted this code from somewhere? There are often unicode/linebreak characters you can't see in the AS editor. – dev Sep 01 '18 at 10:59
  • 1
    Not that I know. I have also tried to copy the working string-array above, from the same file, which has not that problem.. But it doesn't help... – Bosancero Sep 01 '18 at 11:03
  • 1
    Make a backup copy of `values.xml`, or ensure that your current version is in version control. Delete all of the `` elements from the `textFontSizeValues` array. Then try to build the APK and see if the compile error goes away. If it does, then there really is something fishy with those `` elements, and it may be simplest just to re-key them in. If the compile error remains, restore your backed-up `values.xml`... and I'm not sure where to go from there (beyond the standard "Build > Clean Project" recommendation). – CommonsWare Sep 01 '18 at 11:09
  • Beyond that... why do you need an array of **strings**, if it contains **integers**? – Phantômaxx Sep 01 '18 at 11:28
  • Where to find the "values.xml" file? I haven't found it... I deleted all the `` elements from the `textFontSizeValues` array, and tried a new "Build > Clean Project" which still does not successfully compile due to the same errors (this time only the line numbers info is different) :( – Bosancero Sep 01 '18 at 11:34

1 Answers1

0

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!