Conversation
Watch faces may reference drawables using the Android resource reference syntax, e.g. resource="@drawable/name", instead of the bare resource name. The Watch Face Format runtime resolves both forms to the same drawable, but the memory footprint validator looked up the raw attribute value in a resource map keyed by bare name and failed with "Asset @drawable/name was not found in the watch face package". Normalize `resource` and `thumbnail` references by dropping the `@type/` (or `@package:type/`) prefix before looking them up, both in the resource collector and in the optimization estimator. Expressions and bare names are left unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Watch faces may reference drawables using the Android resource reference syntax, e.g.
resource="@drawable/name", instead of the bare resource name. The Watch Face Format runtime resolves both forms to the same drawable, but the memory footprint validator looked up the raw attribute value in a resource map keyed by bare name and failed with:even though the drawable is present in the APK.
Change
WatchFaceDocuments.getResourceReference/normalizeResourceReference, which strip the@type/(or@package:type/) prefix from a reference. Expressions ([...]), bare names and empty values are returned unchanged.resourceandthumbnailattributes inWatchFaceResourceCollector, and forresourceinOptimizationEstimator, so both the footprint evaluation and the optimization estimate find the referenced drawable.Testing
WatchFaceDocumentsTestfor the normalization.WatchFaceResourceCollectorTest#collectResources_normalizesAndroidResourceReferences.ResourceMemoryEvaluatorTestlayout case (AndroidResourceReferences.xml, a copy ofImageHiddenInActive.xmlusing@drawable/references) that expects the same footprint as the bare-name layout../gradlew spotlessCheck memory-footprint:jar memory-footprint:testpasses (135 tests, includingGoldenTest). Without the fix, the new reference tests fail with the error above.<Image resource="@drawable/...">: they fail onmainand pass with this change, with the same reported footprint as when the references are rewritten to bare names.