Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internal error parsing svg file in android studio

Start from this month, I was not able to import any svg file though Vector Asset in my laptop, I always get the msg 'Internal error parsing abc.svg'

I tried to import same svg file using android studio in other laptop, it works, but my laptop cannot import anymore.

I was using android studio in my laptop around 2 years and has been go through many updates, but this month suddenly cannot import anymore, I had performed factory reset in my laptop, and re-install android studio again. I tried create new project as well, but it still cannot work, anyone can help me?

enter image description here

like image 792
Kok Soon Avatar asked Apr 18 '18 08:04

Kok Soon


People also ask

Can we use SVG in Android Studio?

Android Studio includes a tool called Vector Asset Studio that helps you add material icons and import Scalable Vector Graphic (SVG) and Adobe Photoshop Document (PSD) files into your project as vector drawable resources.

How can I read SVG files on Android?

You can import an SVG file as a VectorDrawable in Android Studio, follow these steps : "Right-click" on the res folder and select new > Vector Asset. Select the Local File option and browse to your . svg file.

Can I use SVG files in Android Studio?

If you use flat icon for download svg, before download just click on edit and then download! this svg work fine in android studio. I have android studio 3.1.1 There is another bug in decimal numbers in svg viewBox that can be fixed by change decimal to integer (thanks to crgarrido) Show activity on this post.

Is it possible to import full SVG file in asset studio?

Android studio's Asset Studio is easy to import SVG file to resource, but it does not seem to support full SVG and some valid SVG files get an error as "The specified asset could not be parsed".

How to change the page size of an SVG file?

The problem is your SVG file. You must set the page measure to be in pixels. With Inkscape, in Windows, press Ctrl + Shift + D to open the Document Properties. Set the size units to pixels (px). Hope it helps. Let me know if it worked. Show activity on this post. I solved my problem by removing the comma separated values in the viewBox, i.e. I had


1 Answers

UPDATE December 23, 2018

Base on issuetracker seems this bug fixed in Android Studio 3.2 Canary 5 and above so update your android studio is another way to fix! now i use version 3.2.1 and work fine.

OLD ANSWER

Finally i found solution. I don't know what going on but i have same problem and fixed when i download same svg again and open it with notepad++ and export it with different name as svg! and it's work!

EDIT

If you use flat icon for download svg, before download just click on edit and then download! this svg work fine in android studio.

I have android studio 3.1.1

This just a bug in android studio

EDIT 2

There is another bug in decimal numbers in svg viewBox that can be fixed by change decimal to integer (thanks to crgarrido)

Sample :

Change decimal numbers to integers numbers in svg file header

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 375 135.4"> 

Change 135.4 to 135

like image 121
Radesh Avatar answered Sep 22 '22 13:09

Radesh