Internal error parsing svg file in android studio

后端 未结 11 1614
借酒劲吻你
借酒劲吻你 2020-12-28 12:23

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 imp

相关标签:
11条回答
  • 2020-12-28 12:44

    I solved the problem adding width and height to the svg tag.

    Example

    From

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

    To

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 43.42 56.15" width="24" height="24">
    

    I guess Android Studio can't add vectors from svg files without mentioning the dimensions.

    0 讨论(0)
  • 2020-12-28 12:48

    Open your SVG file in Notepad. Round all the decimal values in viewBox ="no decimal values allowed here".

    0 讨论(0)
  • 2020-12-28 12:49

    In my case, I had a decimal value indicating the height, rounded it to an integer solved the issue

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

    Changing the 135.4 to a 136 did the job

    Update

    After that, In the IDE Fatal errors section I constated the following exception:

    The vector assert parser fails when you have a decimal dimension, I reported the issue. I hope it will be fixed soon.

    0 讨论(0)
  • I solved my problem by removing the comma separated values in the viewBox, i.e. I had

    viewBox="0, 0, 350,450"

    and changing it to

    viewBox="0 0 350 450"

    allowed it to be imported

    0 讨论(0)
  • 2020-12-28 12:52

    I used Gimp and Export Path to produce a simple SVG. It had the width and height as decimal inches. Changing these to the pixel width/height fixed it.

    0 讨论(0)
提交回复
热议问题