1.开发时提示error: XML or text declaration not at start of entity.
在gradlew命令后面arguments中添加–stacktrace -info ,再次编译定位具体出错的文件,最后发现时布局文件中声明了两次version和encoding。
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
2.在Vector中使用android:strokeColor="?attr/themeDefColor"app主体中预定义的颜色时,提示如下错误
Resource references will not work correctly in images generated for this vector icon for API < 24; check generated icon to make sure it looks acceptable
解决办法:在app模块build.gradle的defaultConfig配置项中添加
vectorDrawables.useSupportLibrary true
来确保在低版本来支持矢量图
XML错误与矢量图支持问题解决
在Android开发中遇到XML错误,原因是布局文件中重复声明了version和encoding。通过添加--stacktrace-info参数定位并修复了问题。此外,为使低版本设备支持VectorDrawable,需在build.gradle中启用vectorDrawables.useSupportLibrary。
2055

被折叠的 条评论
为什么被折叠?



