Why is my SVG failing to load in Vector Asset Studio

↘锁芯ラ 提交于 2019-12-02 23:26:14

Android Studio's Vector Asset Studio is currently not support all the features of SVG. You can convert SVG to VectorDrawable using this tool.

Hope it helps.

Kingsley Adio

You need to change the width and height of the svg from mm to use px instead. This is a current workaround pending when the issue is fixed.

There is already a filed bug report here

After spending some hours, I figured out the problem, and even using external svg2vectordrawable scripts couldn't help.

The size of the shapes and/or the document's page size cannot contain floating numbers in its width/height such as 14.134 or 3.5

Meaning the width and height of the shape and the page must be integers!

As @Kingsley Adio said, you must use px units for your SVG document.
In Inkscape, I managed to do it by creating a custom page size and setting the output unit to px:

Importing the .svg files produced in Inkscape into Adobe Illustrator and exporting them fixed this issue 100%.

Compilation of things that worked for me when trying to import SVGs with the Vector Asset tool (they are not mutually exclusive):

  • Change values from mm to px (typically found in the width / height attributes)
  • Round values float values to integer (typically found in the width / height or viewBox or style attributes). Like 224.5. You won't have to do this in the polygons, but only on the SVG node.
Hill Karimov

Changing Text to Object fixed this issue for me. If you are using Inkscape: first click Ctrl+K (Path Combine) then Ctrl+J (Dynamic Offset).

There are various option that might cause such an error (some of them listed here).

On causing could be the use of rgba(r,g,b,a) in your .svg file. Just check and convert if found.

Hint: You can edit .svg fils in any file editor.

Changing the language in settings helped me! I had Dutch as language on my computer (where comma's are used instead of floating points) and changing it to English and restarting worked for me.

My SVG was being created (from an online website) with , in the viewbox tag.

i.e:

viewBox="0, 0, 350,450"

changing this to:

viewBox="0 0 350 450"

allowed Android Studio to import it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!