Shopify Sep 22, 2022

Lessons Building Android Widgets

Article Summary

Matt Bowen and the Shopify team discovered their Android widgets were making up to 5 unnecessary network calls per update cycle. Their solution? A clever 60-second cache that transformed widget performance.

Shopify's mobile team rebuilt their Android widgets from scratch to match their iOS 14 redesign, creating a data-rich experience for merchants to monitor business metrics. The team tackled unique Android challenges including RemoteViews limitations, dynamic layouts for Android 12, and the complexities of building widgets outside React Native.

Key Takeaways

Critical Insight

Building production Android widgets requires creative workarounds for RemoteViews constraints, aggressive caching to prevent redundant updates, and careful buffer management for complex layouts.

The team's widget migration strategy hit an unexpected wall that forced them to deprecate old widgets rather than transform them in place.

About This Article

Problem

Shopify's Android widget configuration screen couldn't track analytics when merchants resized widgets on Android 12. The onAppWidgetOptionsChanged() method didn't have access to the view mapping needed to figure out which layout size was being used.

Solution

The team tried mapping width and height measurements in dp back to layout sizes. After testing on multiple devices, they realized this approach was unreliable and would produce inaccurate analytics data.

Impact

Shopify removed the reconfiguration analytics event from Android altogether. They're hoping this limitation gets enough attention that Google will address it in a future Android release.

Recent from Shopify

Related Articles