Want your Android lint check to run a little faster? Have an Android project which doesn't support Android Wear (WearOS) devices?
Add the following to your lint.xml
<issue id="InvalidWearFeatureAttribute" severity="ignore" />
<issue id="SquareAndRoundTilePreviews" severity="ignore" />
<issue id="TilePreviewImageFormat" severity="ignore" />
<issue id="TileProviderPermissions" severity="ignore" />
<issue id="WatchFaceEditor" severity="ignore" />
<issue id="WatchFaceForAndroidX" severity="ignore" />
<issue id="WatchFaceFormatDeclaresHasNoCode" severity="ignore" />
<issue id="WatchFaceFormatMissingVersion" severity="ignore" />
<issue id="WatchFaceFormatInvalidVersion" severity="ignore" />
<issue id="WearableActionDuplicate" severity="ignore" />
<issue id="WearableConfigurationAction" severity="ignore" />
<issue id="WearStandaloneAppFlag" severity="ignore" />
<issue id="WearSplashScreen" severity="ignore" />
<issue id="WearRecents" severity="ignore" />
<issue id="WearPasswordInput" severity="ignore" />
<issue id="WearMaterialTheme" severity="ignore" />
<issue id="WearBackNavigation" severity="ignore" />
What the helly?
Whilst profiling the lint task on an Android project I noticed that around 5% of overall time taken could be attributed to Android Wear checks. This was weird as the project didn't have support for Android Wear!
The longest running Wear related lint detector was the following
WearDetector 2846 ms
Looking up the source for this you can see it's a base class which other detectors can inherit from.
Some detectors correctly use the base class to only register interest in ast symbols if wear is enabled. However most don't, and that means these detectors run even on non wear projects.
WearDetector itself parses the merged manifest associated with your projects in order to determine if they support wear devices. However this call is not cached, meaning every implementor of WearDetector which calls the function isWearProject
causes the linter to reparse the manifest.
In order to avoid a detector running you must ignore all the checks they register, ignoring one is not sufficient. The above xml does just that for android wear related checks.
WearDetector 0 ms
If you're wondering about the profiler I used, it's here. It's not very well maintained tbh and I had to rewrite parts of the project to make it work. It also depends on a proprietary JVM profiler which costs money... but theres a trial if you're keen
Top comments (0)