| got this error when try to generate a vector asset from local svg files from AndroidStudio 2.2, Ubuntu 14.04
Could not generate a preview
In icon.svg
ERROR@ line 6 <defs> is not supported
ERROR@ line 25 <use> is not supported
I google and found that happened because AndroidStudio doesn't support <defs>
, <use>
...
But I don't know how to fix it?
Can I change <defs>
to another tag that AndroidStudio support?
Or I never can generate vector asset from this SVG file?
Any help or suggestion would be great appreciated.
Your SVG uses a
<linearGradient>
and, to make the faint shadow, it uses an SVG filter (<filter>
). Neither of these are supported by VectorDrawables. So any solution would involve removing those.It looks like the file was created in Sketch. You can try removing those items in Sketch and trying the import again.
If that still doesn't work then you may have to manually fix the other element that is not supported by the importer:
<use>
. The good news is that it is easy to work around.I've included a manually edited version of the file below that fixes those three issues. It should import into Android Studio okay, but I don't know whether it meets your aesthetic needs or not.
I was having the same problem when importing svg directly from sketch into the android studio, I used this tool to convert it to vector drawable and then importing it.