4

Android Studio reported out:

unescaped or nonterminated entity/reference

When tried to use "and", does anyone know how to fix it?

Error tooltip screenshot

Christos Lytras
  • 36,310
  • 4
  • 80
  • 113
Thomas Tong
  • 51
  • 2
  • 4

2 Answers2

7
'&' --> '&'

'<' --> '&lt;'

'>' --> '&gt;'

Work for me

 android:background="@{entry.boolean &amp;&amp; entry.boolean2 ? @drawable/image :@drawable/image2}"
Roman Irtov
  • 363
  • 3
  • 12
1

The issue is that even inside quotation marks, Android is looking for the ampersand (&) to mean something. To let it know that you REALLY are just using it as text, you have to code it out by entering it as "&" (without the quotation marks - that's just there to show that you have to have all five of those characters).
I got the same error, and as soon as I changed "&" to "&" error went away. Hope this helps.

Kevin
  • 11
  • 3
  • At least, this isn't working when you write in the strings.xml resource file. I know is not the same case, but it's very close. Any ideas @Kevin ? – xarlymg89 Mar 27 '18 at 09:36
  • Just got the answer in a different post https://stackoverflow.com/questions/3053062/how-can-i-write-character-in-android-strings-xml Actually this is absolutely not related with this issue. Now I see it was an expression, and not a string. – xarlymg89 Mar 27 '18 at 09:55