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. 用记事本打开以下两个文件,并且把标签内的 ‘<’ 和 ‘>’ 字符分别替换成 "<” 和 “>”。

  • 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

更多相关文章

  1. android的布局文件简介
  2. Android 数据存储之文件存储小记
  3. Android软件安装文件夹
  4. 详细解读Android中的搜索框(四)—— Searchable配置文件
  5. Android Studio 指定DEBUG和RELEASE版本打包时的APK文件名
  6. Android中使用 MediaExtractor 和 MediaMuxer解析、封装 mp4 文
  7. android:shape的使用 (android用xml文件生成图像控件)
  8. Android解析Xml字符串例子
  9. android 自定义View 在布局文件中写法

随机推荐

  1. Android性能优化(2):常见内存泄漏与优化(二
  2. android listview 使用checkbox问题
  3. Android(安卓)webview调用js代码无效 web
  4. Android屏幕元素层次结构
  5. Android(安卓)Studio实现本地视频播放
  6. TabLayout用法,android顶部导航栏,android
  7. Android(安卓)开发技术周报 Issue#279
  8. 使用Python开发Android应用程序:第一节 在
  9. portrait表示纵向,landscape表示横向
  10. Android高效加载大图、多图解决方案,有效