Shopify2023-10-18Explainer
Lessons From Building Android Widgets
Summary
Shopify revisited its Android widgets alongside an iOS widget effort, aiming to give merchants faster access to frequently changing business metrics. The team chose native Android development because React Native lacked official RemoteViews support, while widget configuration data was persisted with shared preferences and used to build requests. Because Android could invoke onUpdate() multiple times per cycle, they added a one-minute, short-lived cache keyed by widgetID and mindful of configuration such as locale. This reduced redundant network calls, system load, and incorrect analytics, while the widget rollout also exposed migration limitations between old fixed-size widgets and new space-responsive ones, leading Shopify to deprecate the old widgets rather than transform them.
Context
Shopify’s widgets provide merchants with quick access to analytics and business metrics, but the metrics need to be fresh without causing excessive network usage. The team also needed to replace existing Android widgets while maintaining a consistent experience across Android and iOS and accounting for platform-specific constraints.
Approach / What changed
The team built the widgets natively because React Native lacked official support for Android RemoteViews. Widget configuration was stored with shared preferences, dynamic metric definitions shaped requests and decoding, and a short-lived cache prevented repeated network calls during duplicate update callbacks. For the transition to the new widgets, Shopify deprecated the old fixed-size widgets and used in-widget messaging and help-center documentation to guide merchants.
Takeaways
Android widget updates can trigger onUpdate() multiple times in a cycle, causing duplicate network requests when every update fetches fresh data.
A one-minute cache keyed by widgetID, with configuration such as locale included in the cache decision, reduced unused network calls, system load, and incorrect analytics.
Shopify could not reliably transform fixed-size legacy widgets into new widgets that use available space, so it deprecated the old widgets alongside the new release.
Source and freshness
- Source
- shopify.engineering
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.