Android Vector Drawable 崩溃

Android Vector Drawable crash

我使用 Vector Drawables。它在我的几台设备上运行良好,但在我的 Android 5.0.2 索尼上,我在应用程序启动时得到:

java.lang.ArrayIndexOutOfBoundsException: length=32; index=32
 at android.util.PathParser$PathDataNode.addCommand(PathParser.java:370)
 at android.util.PathParser$PathDataNode.nodesToPath(PathParser.java:260)
 at android.graphics.drawable.VectorDrawable$VPath.toPath(VectorDrawable.java:1265)
  at android.graphics.drawable.VectorDrawable$VPathRenderer.drawPath(VectorDrawable.java:950)

看起来我有一些 svgs 转换为 xml,带有不支持此设备的标签。但是如何了解哪些以及如何确保它可以在所有其他受支持的设备上运行。

同样的问题http://code.google.com/p/android/issues/detail?id=78162 (Closed: Oct 2014) Problem was that one of my vector xml contained a scientific notation

所以此时要确保您的应用程序可以在所有设备上运行,请确保您的 xml 矢量绘图不包含 e-

在寻找解决方案时,我找到了一些解决方法,例如将 OS 语言切换为英语。

您可以在问题跟踪器中阅读更多内容 here and here

通过 Android SVG to VectorDrawable 传递我的 svg 后出现此错误。原来它生成的一些路径在第一个数字之后有字母 'L'。删除它修复了错误。

这个错误可能发生在Android 5.0.1 原因:存在科学格式(科学计数法)的矢量图像描述符编号,例如 8.8e-5

在项目中的矢量图像标签中查找以下条目

解决方案:在这种情况下,决定在没有参展商的情况下更改格式中的这些数字将是结果,0.000088

在我的 xml 中存在 <group></group> 个属性。

他们的去除问题解决后,也花了一些时间了解问题出在哪里,不是M和L字母(阅读更多:https://developer.mozilla.org/en/docs/Web/SVG/Tutorial/Paths