my partner in ours\' project use android databinding.in my pc had error,but in his mac not error.i cant resolve this program.please help!! it\'s my build gradle:
<
Suffered the same problem for one day, finally found out the root cause. Andoid gradle plugin does not handle the encoding with Byte order mark (BOM) well. It is a encoding reading problem.
If the file is saved in UTF-8 BOM format, Android gradle tool will detect the encoding as “UTF-8” with UniversalDetector library. The class android.databinding.tool.store.LayoutFileParser
will read like this:
InputStreamReader reader = new InputStreamReader(fin, “UTF-8”);
The first character returned by reader.read()
is 0xfeff
. Yes it is the ‘?’ in error message line 1:0 mismatched input '?' expecting {COMMENT, SEA_WS, '<', PI}
.
Refer the magic number of BOM at https://en.wikipedia.org/wiki/Byte_order_mark
How UniversalDetector works at http://chardet.readthedocs.io/en/latest/how-it-works.html