19

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.

Community
  • 1
  • 1
Nilesh Pawar
  • 3,895
  • 3
  • 21
  • 19
  • 1
    It's possible this feature isn't available on first 1.3 preview, if you listen closely mr Eason says "so soon, with Android Studio.." – harism Jun 01 '15 at 19:35
  • @Nilesh Ever make headway on this topic? I'd like to use this feature in Android Studio as well... – IgorGanapolsky Jun 09 '15 at 18:33
  • @IgorGanapolsky I think it has not been released by google until now. So i will be waiting for the google guys to provide some documentation. – Nilesh Pawar Jun 10 '15 at 21:22
  • @NileshPawar Typical google - they announce a feature at IO, and then don't release it. – IgorGanapolsky Jul 17 '15 at 15:31
  • 1
    This feature was supposed to be released in 1.3, but [AS 1.3 release notes](http://tools.android.com/recent/androidstudio13betaavailable) state "Similarly, the vector rasterization support is also still not enabled due to various bugs." – Adam Johns Aug 02 '15 at 20:52
  • 3
    A bit of an update http://tools.android.com/recent/androidstudio14preview1incanarychannel Don't miss the fine print. This change will be in gradle 1.4 which hasn't been released for preview yet. – Stimsoni Aug 26 '15 at 00:25
  • @Stimsoni thanks for the update. – Nilesh Pawar Aug 26 '15 at 22:37

1 Answers1

8

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

Community
  • 1
  • 1
crysxd
  • 3,177
  • 20
  • 32
  • I already have an SVG asset. How to force Anrdoid Studio to generate a bunch of PNGs from it, for all possible resolutions, replacing the existing images? – Paul Aug 29 '22 at 13:09