Posted by Android Team

In 2020, the mercury The team has taken a major initiative to update the technical infrastructure of their app. At the time, its codebase was seven years old and had not undergone any major architectural updates. This affected the team’s ability to develop new features and release app updates in a timely manner. To address this technical debt, Mercari launched what it called the Groundup initiative — a complete rewrite of its applications across all platforms, including Android.

The goal was to create a completely modern application with a scalable design. When re-tooling the app, Mercari developers turned to jetpack design, Android’s modern declarative toolkit for building native UIs. During evaluation, the team learned that rewriting in Jetpack Compose would help clean up their codebase and have more control over how the app looks.

a rewrite with less code

The Mercari team completely rewrote the architecture and tech stack for their Android app using Jetpack Compose. Mercari developers created a new design system and fully integrated it using Compose, allowing them to easily test and implement new features. Using this new design methodology, the Mercari team rewrote over 130 UI screens for their marketplace and modernized the look and feel of many of their components.

with the help of jetpack libraryDuring the rewrite, Mercari’s team removed all legacy code, reducing its codebase significantly and making it more manageable for developers. “Effectively, it’s a single app with less code,” said Alan Konda, head of Android technology at Mercury. “The rewritten app has about 355,000 fewer lines of code, which is about 69% fewer than before.”

Moving image showing lines of code appearing and disappearing on the leftmost panel of the screen.  The spacing between boxes in the center panel changes, and the overall app view reflects these changes in the rightmost panel.

Interoperability with Views as an early adopter

When the Mercari team first launched their GroundUp initiative, Jetpack Compose was only available in developer preview. They wanted the app to be written entirely in Jetpack Compose because of their new declarative approach to building the UI. However, because it was still so new, they found that using both toolkits required them to solve unique edge cases.

For example, on Mercari’s listing form screen, users are asked to provide details about the merchandise they wish to list. Users were then able to select photos from their device gallery and rearrange them on this screen using drag gestures. Gesture APIs were not available in Jetpack Compose at the time, so the team took advantage of Compose’s AndroidView to seamlessly integrate views that handle gestures on the listing form screen. This provided a stable but temporary solution for implementing drag gestures until the feature was available with Jetpack Compose.

The Mercari team was impressed with how easy it was to switch between the two toolkits, and having the option to use Compose as well as Views gave them better control of edge cases like this. Compose now supports the Gesture API, and the Mercury developers have since rewritten and integrated the drag gesture component entirely using Compose.

Jetpack Compose has matured significantly since the early adoption of Mercari, and most Android developers no longer need to worry about interoperating with both toolkits as Android apps can now be written entirely in Compose. .

Improving and monitoring performance with Compose

Using Compose, the Mercari team automated baseline profile generation for every stable release of the app and found it really helpful. The Home Screen renders frames 2x faster with the default Compose Baseline Profile than without the Baseline Profile. By providing a custom profile, there is up to an additional 20% improvement when Mercari users are scrolling compared to the default baseline profile.

The team also wrote automated performance tests based on key scenarios of the app Android Macrobenchmark, “Using Android Macrobenchmark, we can automatically test start-up, scroll and screen load time performance,” Allen said. “Currently, we have six main scenarios covered by these tests, such as search results and browsing items.”

Additionally, Mercari developers integrate firebase performance monitoringA real-time app performance monitoring tool with custom code to calculate scrolling performance on the compose screen. With Firebase Performance Monitoring, the Mercari team detected a performance issue on their search results screen. Using the android profiler To pinpoint the problem, the Mercury developers discovered poor frame rates when scrolling through search results. This resulted in a reduction of slow rendering instances by approximately 23.6%.

Mercari team resolved this frame rate issue with guidance from Google Build performance best practices And write stability, Mercari Developers abandoned the app composables And hoist unused states Significantly improves the frame rate on the search results screen.

Headshot of Alan Konda, Android Tech Lead at Mercury, emulating with quote text, 'Jetpack Compose helped us implement our design system and rewrite 130+ screens and many of our components'

More opportunities with Jetpack Compose

With less code to maintain, it is much easier for Mercari developers to test and implement features. “We have a ton of experiments that we can ultimately conduct using our refreshed platform. Our users can expect new features to come to the Mercury app quickly,” Allen said.

Mercari’s developers are excited to use and grow the app Animation API, With Compose, it’s much easier to animate components, which can result in huge improvements to Android UX.

get started

Optimize your UI development with jetpack design,

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *