Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 745
Travis Griggs Avatar asked Feb 28 '20 23:02

Travis Griggs


People also ask

How do I bulk import SVGS into Android Studio?

The Resource Manager tool that was added in Android Studio version 3.4 can bulk import SVGs and convert them into vector drawables. There you can select all the files you want to import at once.

How to install batch drawable in Android Studio?

From Android studio -> Goto Configure->plugins. Search for "Batch Drawable importer" . Click Install. Then restart android studio. Show activity on this post.

What is drawable importer in Android Studio?

Drawable Importer is plugin for android studio which is used to generate icons in multiple size (for all supported sized). So it reduces the time and efforts to make icons for all supported devices. If you haven’t tried this plugin then you should try this, it will help you to increase development speed.

Is there a way to import image assets in Android Studio?

Two years later, Android Studio has a way to import Image Assets. But I wanted to add a new comment. Android now supports Vectors, so we don't have to worry about different resolutions.


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.

like image 140
Steven Meliopoulos Avatar answered Nov 11 '22 18:11

Steven Meliopoulos


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.

like image 41
Pratik Butani Avatar answered Nov 11 '22 17:11

Pratik Butani