(#) Long vector paths !!! WARNING: Long vector paths This is a warning. Id : `VectorPath` Summary : Long vector paths Severity : Warning Category : Performance Platform : Android Vendor : Android Open Source Project Feedback : https://issuetracker.google.com/issues/new?component=192708 Affects : Resource files Editing : This check runs on the fly in the IDE editor Implementation : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/VectorPathDetector.java) Tests : [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/VectorPathDetectorTest.java) Copyright Year : 2017 Using long vector paths is bad for performance. There are several ways to make the `pathData` shorter: * Using less precision * Removing some minor details * Using the Android Studio vector conversion tool * Rasterizing the image (converting to PNG) (##) Example Here is an example of lint warnings produced by this check: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text res/drawable/my_vector.xml:16:Warning: Very long vector path (1622 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector. [VectorPath] android:pathData="@string/airplane_mask_clip_path_enabled"/> --------------------------------------- res/drawable/my_vector.xml:37:Warning: Very long vector path (1623 characters), which is bad for performance. Considering reducing precision, removing minor details or rasterizing vector. [VectorPath] android:pathData="M 37.8337860107,-40.3974914551 c 0,0 -35.8077850342,31.5523681641 -35.8077850342,31.5523681641 c 0,0 40.9884796143,40.9278411865 40.9884796143,40.9278411865 c 0,0 -2.61700439453,2.093… ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------… ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here is the source file referenced above: `res/drawable/my_vector.xml`: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers <vector xmlns:android="http://schemas.android.com/apk/res/android" android:name="root" android:width="48dp" android:height="48dp" android:tint="?attr/colorControlNormal" android:viewportHeight="48" android:viewportWidth="48"> <group android:translateX="-1.21595" android:translateY="6.86752"> <clip-path android:name="maskClipPath" android:pathData="@string/airplane_mask_clip_path_enabled"/> <path android:name="crossPath" android:pathData="@string/airplane_cross_path" android:strokeColor="@android:color/white" android:strokeWidth="3.5" android:trimPathEnd="0"/> <group android:translateX="23.481" android:translateY="18.71151"> <path android:fillColor="@android:color/white" android:pathData="@string/airplane_path"/> </group> <group android:translateX="23.481" android:translateY="18.71151"> <path android:fillColor="@android:color/white" android:pathData=""/> </group> </group> </vector> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also visit the [source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/VectorPathDetectorTest.java) for the unit tests for this check to see additional scenarios. The above example was automatically extracted from the first unit test found for this lint check, `VectorPathDetector.testBasic`. To report a problem with this extracted sample, visit https://issuetracker.google.com/issues/new?component=192708. (##) Suppressing You can suppress false positives using one of the following mechanisms: * Adding the suppression attribute `tools:ignore="VectorPath"` on the problematic XML element (or one of its enclosing elements). You may also need to add the following namespace declaration on the root element in the XML file if it's not already there: `xmlns:tools="http://schemas.android.com/tools"`. * Using a special `lint.xml` file in the source tree which turns off the check in that folder and any sub folder. A simple file might look like this: ```xml <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="VectorPath" severity="ignore" /> </lint> ``` Instead of `ignore` you can also change the severity here, for example from `error` to `warning`. You can find additional documentation on how to filter issues by path, regular expression and so on [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html). * In Gradle projects, using the DSL syntax to configure lint. For example, you can use something like ```gradle lintOptions { disable 'VectorPath' } ``` In Android projects this should be nested inside an `android { }` block. * For manual invocations of `lint`, using the `--ignore` flag: ``` $ lint --ignore VectorPath ...` ``` * Last, but not least, using baselines, as discussed [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).