Batch import SVGs as Drawables in AndroidStudio 3.6 (How?)

Viewed 3171

I have quite a few (208 currently) SVG files that I programmatically turn into .imageset assets for my iOS app. I'd like to do the same for Android somehow.

I'm pretty pleased with the result I get by using New>>Vector Asset from the Studio menu. But I really don't want to do that 208 times. And more times in the future when the SVGs get updated.

Is there a way I can somehow script this import process?

I don't want to batch process them on some website somewhere. And I'd like to use the current studio tools if possible somehow. Or a completely independent command line tool.

2 Answers

The Resource Manager tool that was added in Android Studio version 3.4 can bulk import SVGs and convert them into vector drawables.

  1. ToolsResource Manager
  2. Select the Drawable tab
  3. Click the + button in the top left corner
  4. Select Import Drawables

There you can select all the files you want to import at once. More details here.

You can download this jar file: Svg2VectorAndroid-1.0.1.jar

Just run this command:

java -jar C:\Users\Administrator\Downloads\Svg2VectorAndroid-1.0.1.jar C:\Users\Administrator\Desktop\your_svg_folder

Hope it will work for you.

Related