android databinding error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'

后端 未结 5 1122
不思量自难忘°
不思量自难忘° 2021-01-02 18:06

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:

<         


        
5条回答
  •  说谎
    说谎 (楼主)
    2021-01-02 18:23

    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

提交回复
热议问题