Fixed
Status Update
Comments
al...@gmail.com <al...@gmail.com> #2
I originally discovered this bug while attempting to convert the following `visa.svg` file to VectorDrawable:
<svg xmlns="http://www.w3.org/2000/svg " width="500" height="500" viewBox="0 0 24 24">
<path fill="#000" d="
M11.03 14.333H9.591l.9-4.973h1.44l-.901 4.973
M8.36 9.36l-1.35 3.42-.16-.736h.001l-.476-2.236s-.057-.448-.671-.448h-2.23l-.027.084s.683.13 1.48.568l1.23 4.32h1.475L9.883 9.36H8.36
m11.357 4.973H21L19.88 9.36h-1.123c-.52 0-.645.37-.645.37l-2.085 4.603h1.457l.291-.739h1.777l.165.739z
m-1.539-1.76l.735-1.86.413 1.86h-1.148z
m-2.068-2.191l.21-1.093s-.647-.222-1.32-.222c-.73 0-2.459.287-2.459 1.684 0 1.315 2.03 1.33 2.03 2.021 0 .69-1.82.567-2.421.132l-.219 1.142s.655.287 1.657.287c1.001 0 2.512-.468 2.512-1.742 0-1.322-2.048-1.445-2.048-2.02 0-.576 1.43-.502 2.058-.19
"/>
</svg>
Android Studio incorrectly converted the SVG to the following:
<vector android:height="24dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android ">
<path android:fillColor="#000" android:pathData="
M11.03,14.333L9.591,14.333l0.9,-4.973h1.44l-0.901,4.973
M8.36,9.36l-1.35,3.42 -0.16,-0.736h0.001l-0.476,-2.236s-0.057,-0.448 -0.671,-0.448h-2.23l-0.027,0.084s0.683,0.13 1.48,0.568l1.23,4.32h1.475L9.883,9.36L8.36,9.36
m11.357,4.973L21,14.333L19.88,9.36h-1.123c-0.52,0 -0.645,0.37 -0.645,0.37l-2.085,4.603h1.457l0.291,-0.739h1.777l0.165,0.739z
M6.821,7.6l0.735,-1.86 0.413,1.86h-1.148z
M4.753,5.409l0.21,-1.093s-0.647,-0.222 -1.32,-0.222c-0.73,0 -2.459,0.287 -2.459,1.684 0,1.315 2.03,1.33 2.03,2.021 0,0.69 -1.82,0.567 -2.421,0.132l-0.219,1.142s0.655,0.287 1.657,0.287c1.001,0 2.512,-0.468 2.512,-1.742 0,-1.322 -2.048,-1.445 -2.048,-2.02 0,-0.576 1.43,-0.502 2.058,-0.19"/>
</vector>
So clearly Android Studio is doing something funky with relative/absolute move to commands...
I attached two screenshots of what the initial SVG looked like when displayed in Chrome, as well as the vector drawable preview displayed in Android Studio.
<svg xmlns="
<path fill="#000" d="
M11.03 14.333H9.591l.9-4.973h1.44l-.901 4.973
M8.36 9.36l-1.35 3.42-.16-.736h.001l-.476-2.236s-.057-.448-.671-.448h-2.23l-.027.084s.683.13 1.48.568l1.23 4.32h1.475L9.883 9.36H8.36
m11.357 4.973H21L19.88 9.36h-1.123c-.52 0-.645.37-.645.37l-2.085 4.603h1.457l.291-.739h1.777l.165.739z
m-1.539-1.76l.735-1.86.413 1.86h-1.148z
m-2.068-2.191l.21-1.093s-.647-.222-1.32-.222c-.73 0-2.459.287-2.459 1.684 0 1.315 2.03 1.33 2.03 2.021 0 .69-1.82.567-2.421.132l-.219 1.142s.655.287 1.657.287c1.001 0 2.512-.468 2.512-1.742 0-1.322-2.048-1.445-2.048-2.02 0-.576 1.43-.502 2.058-.19
"/>
</svg>
Android Studio incorrectly converted the SVG to the following:
<vector android:height="24dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="
<path android:fillColor="#000" android:pathData="
M11.03,14.333L9.591,14.333l0.9,-4.973h1.44l-0.901,4.973
M8.36,9.36l-1.35,3.42 -0.16,-0.736h0.001l-0.476,-2.236s-0.057,-0.448 -0.671,-0.448h-2.23l-0.027,0.084s0.683,0.13 1.48,0.568l1.23,4.32h1.475L9.883,9.36L8.36,9.36
m11.357,4.973L21,14.333L19.88,9.36h-1.123c-0.52,0 -0.645,0.37 -0.645,0.37l-2.085,4.603h1.457l0.291,-0.739h1.777l0.165,0.739z
M6.821,7.6l0.735,-1.86 0.413,1.86h-1.148z
M4.753,5.409l0.21,-1.093s-0.647,-0.222 -1.32,-0.222c-0.73,0 -2.459,0.287 -2.459,1.684 0,1.315 2.03,1.33 2.03,2.021 0,0.69 -1.82,0.567 -2.421,0.132l-0.219,1.142s0.655,0.287 1.657,0.287c1.001,0 2.512,-0.468 2.512,-1.742 0,-1.322 -2.048,-1.445 -2.048,-2.02 0,-0.576 1.43,-0.502 2.058,-0.19"/>
</vector>
So clearly Android Studio is doing something funky with relative/absolute move to commands...
I attached two screenshots of what the initial SVG looked like when displayed in Chrome, as well as the vector drawable preview displayed in Android Studio.
al...@gmail.com <al...@gmail.com> #3
I believe the issue may be related to this chunk of code: https://android.googlesource.com/platform/tools/base/+/studio-3.2.1/sdk-common/src/main/java/com/android/ide/common/vectordrawable/VdPath.java#240
Specifically, I don't think the code in the "if (previousType == 'z' || previousType == 'Z')" statement is updating the currentSegmentStart{X,Y} variables properly.
Specifically, I don't think the code in the "if (previousType == 'z' || previousType == 'Z')" statement is updating the currentSegmentStart{X,Y} variables properly.
rm...@google.com <rm...@google.com> #4
Thank you for your feedback. Team may reach out for more feedback in reproducing or triaging this issue.
al...@gmail.com <al...@gmail.com> #5
Any updates on this?
I've encountered another SVG that converts incorrectly due to this bug:
<svg xmlns="http://www.w3.org/2000/svg " width="32" height="32" viewBox="0 0 32 32">
<path fill="#292936" fill-rule="evenodd" d="M28 16c0 6.628-5.372 12-12 12-6.627 0-12-5.372-12-12S9.373 4 16 4c6.628 0 12 5.372 12 12zm-11.842.897a3.46 3.46 0 0 0 3.45-3.45A3.46 3.46 0 0 0 16.158 10a3.459 3.459 0 0 0-3.448 3.448 3.46 3.46 0 0 0 3.448 3.45zm7.092 4.196A9.818 9.818 0 0 0 16 17.92a9.818 9.818 0 0 0-7.25 3.173 8.35 8.35 0 0 0 7.25 4.2 8.35 8.35 0 0 0 7.25-4.2z"/>
</svg>
I've encountered another SVG that converts incorrectly due to this bug:
<svg xmlns="
<path fill="#292936" fill-rule="evenodd" d="M28 16c0 6.628-5.372 12-12 12-6.627 0-12-5.372-12-12S9.373 4 16 4c6.628 0 12 5.372 12 12zm-11.842.897a3.46 3.46 0 0 0 3.45-3.45A3.46 3.46 0 0 0 16.158 10a3.459 3.459 0 0 0-3.448 3.448 3.46 3.46 0 0 0 3.448 3.45zm7.092 4.196A9.818 9.818 0 0 0 16 17.92a9.818 9.818 0 0 0-7.25 3.173 8.35 8.35 0 0 0 7.25 4.2 8.35 8.35 0 0 0 7.25-4.2z"/>
</svg>
al...@lyft.com <al...@lyft.com> #6
Oops, sorry, I meant this one:
<svg xmlns="http://www.w3.org/2000/svg " width="24" height="24" viewBox="0 0 24 24">
<path fill="#292936" fill-rule="evenodd" d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0m-6.674-2.175A2.333 2.333 0 0 1 12 12.151a2.333 2.333 0 0 1-2.325-2.326A2.332 2.332 0 0 1 12 7.5a2.333 2.333 0 0 1 2.326 2.325zm3.174 6.07a6.334 6.334 0 0 1-5.5 3.186 6.334 6.334 0 0 1-5.5-3.186 7.448 7.448 0 0 1 5.5-2.407c2.186 0 4.14.93 5.5 2.407z"/>
</svg>
<svg xmlns="
<path fill="#292936" fill-rule="evenodd" d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0m-6.674-2.175A2.333 2.333 0 0 1 12 12.151a2.333 2.333 0 0 1-2.325-2.326A2.332 2.332 0 0 1 12 7.5a2.333 2.333 0 0 1 2.326 2.325zm3.174 6.07a6.334 6.334 0 0 1-5.5 3.186 6.334 6.334 0 0 1-5.5-3.186 7.448 7.448 0 0 1 5.5-2.407c2.186 0 4.14.93 5.5 2.407z"/>
</svg>
sp...@google.com <sp...@google.com>
sp...@google.com <sp...@google.com> #7
Thank you, Alex, for the excellent bug reports.
al...@gmail.com <al...@gmail.com> #8
Thank YOU for fixing them so quickly! I seriously appreciate it. :)
jo...@gmail.com <jo...@gmail.com> #9
Any insight in which version this fix will ship? 3.4 beta? :-)
ca...@google.com <ca...@google.com> #10
This should be in 3.5 canary 7 unless Sergey thinks that it should be cherry picked in 3.4.
@Saurabh, can this be cherry picked?
@Saurabh, can this be cherry picked?
sp...@google.com <sp...@google.com> #11
3.4 beta will have the fix too.
Description
Build #AI-183.4588.61.34.5173923, built on December 10, 2018
JRE: 1.8.0_152-release-1248-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.2
The following SVG fails to convert properly to VectorDrawable (see the attached visa.svg file):
<svg xmlns="
<path fill="#000" d="
M0 0
m10 10 h -10 v -10 h 10 v 10 z
m-2-2 v -6 h -6 v 6 h 6
"/>
</svg>
When converted to VectorDrawable using Android Studio, the output is:
<vector
xmlns:android="
android:width="24"
android:height="24"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000"
android:pathData="
M0,0
m 10 10 h 10 v -10 h 10 v 10 z
M -2 -2 v -6 h -6 v 6 h 6"
/>
</vector>
Notice how the 3rd subpath in the original SVG begins with a relative "m" move to command. However, in the converted VectorDrawable, the third subpath incorrectly begins with an absolute "M" command instead.