Android构建时报错: java.io.IOException: Could not parse XML from android/accounts/annotations.xml

Android构建时报错:

app:lintVitalRelease[Fatal Error] :3:214: 与元素类型 "item" 相关联的 "name" 属性值不能包含 '<' 字符。

Could not read /Users/panxin/Library/Android/sdk/platform-tools/api/annotations.zip

java.io.IOException: Could not parse XML from android/accounts/annotations.xml

原因:sdk下/platform-tools/api/annotations.zip这个文件里的xml文件不规范造成的。

解决方法

  1. 到sdk目录下找到/platform-tools/api/annotations.zip这个文件并解压。

  2. 用记事本打开以下两个文件,并且把标签内的 ‘<’ 和 '>' 字符分别替换成 "&lt;” 和 "&gt;"。

  • android/accounts/annotations.xml
  • android/hardware/camera2/annotations.xml
  • android/hardware/camera2/params/annotations.xml
  • android/app/slice/annotations.xml
  • android/widget/annotations.xml
  • android/view/annotations.xml
  • android/view/textclassifier/annotations.xml
  • android/bluetooth/le/annotations.xml
  • android/media/annotations.xml
  • android/preference/annotations.xml
  • android/text/annotations.xml
  1. 保存并压缩,替换掉原来的annotations.zip文件。

OR~~ 如果不想一个个去修改,可以直接使用我改好的这个annotations.zip文件。

注意(1): 编辑时要用以UTF-8无BOM方式编码,如果被编辑器加了BOM头,会导致另一个错误:
app:lintVitalRelease[Fatal Error] :1:1: 前言中不允许有内容。

注意(2) : 如果报以下错误::app:lintVitalRelease[Fatal Error] :1:1: 前言中不允许有内容。
Could not read /Users/panxin/Library/Android/sdk/platform-tools/api/annotations.zipjava.io.IOException:
Could not parse XML from __MACOSX/annotations/android/hardware/camera2/._annotations.xml
原因是:压缩时Mac系统会往文件里加入系统文件"__MACOSX",
解决办法是:使用终端去压缩:zip -r annotations.zip ./android

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    wgl0419阅读 11,477评论 1 9
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,664评论 2 45
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,593评论 0 3
  • 周六的早上,天气晴朗很适合去湖边、江边漫步,不过这温度,虽然感觉还好,可是走不了几步身上边湿透了。不喜欢一个人在屋...
    林夕无梦阅读 1,683评论 0 0
  • 明明知道晚睡不利于身体健康,可是很多人还是会抱着手机熬夜到深夜一两点钟。明明知道很多东西自己并不是那么需要,但是一...
    流浪地球sf阅读 4,064评论 5 5