Android Studio 1.3 SVG to png conversion

Nilesh Pawar picture Nilesh Pawar · Jun 1, 2015 · Viewed 10.6k times · Source

In recent google IO 2015, google announced that the new Android Studio 1.3/ new gradle plugin will have support for importing and SVG file and the build system will generate the assets for different device densities (hdpi, xhdpi, xxhdpi etc):

http://robovm.com/google-io-summary-whats-new-in-android-development-tools/ https://www.youtube.com/watch?v=f7ihSQ44WO0&feature=youtu.be&t=2m46s

Unfortunately there doesnt seem to be more information about how to achieve that. Does any one have any more details about it?

There is some mention of it in : Android: Using SVG in res leads to error: "The file name must end with .xml or .png"

and I tried to create a hello world app and places an svg file (renamed it to xml in the drawable folder). it compiled and installed on the device, but crashed during execution saying svg is not a vlaid tag. suppose the original file needs more conversion.

Answer

crysxd picture crysxd · Nov 16, 2015

To add a new vector asset right click on your drawable folder in Android Studio and choose New > Vector asset. Please note that you need Gradle 1.4 or newer to use vector assets with projects with a build target lower than 21. In this case Gradle will convert the vector images to PNGs at build time.

The current beta version of Gradle 1.4 has some issues with opening keystores when releasing an apk, so before importing a lot of vector images, try to release your app first (this is only my personal experience with Gradle 1.4.0-beta6, Gradle will report a tampered keystore, e.g. see here)

enter image description here enter image description here