Mercari Mar 27, 2023

Android Developers Blog: Mercari reduces 355K lines of code, a 69% difference, by rebuilding with Jetpack Compose

Article Summary

Mercari just deleted 355,000 lines of code from their Android app. And it works better than ever.

When Mercari's 7-year-old codebase became a bottleneck for shipping features, they made a bold call: rewrite the entire Android app from scratch. They chose Jetpack Compose, Android's modern UI toolkit, for their complete rebuild across 130+ screens.

Key Takeaways

Critical Insight

Mercari's complete rewrite with Jetpack Compose resulted in 69% less code, 2x faster rendering, and a more maintainable codebase that ships features faster.

The team's approach to monitoring performance with Firebase and Macrobenchmark revealed optimization opportunities most teams miss.

About This Article

Problem

Early versions of Jetpack Compose didn't have gesture APIs, so Mercari's team had to work around this limitation. They needed to handle drag interactions on their listing form screens where users rearrange photos from their device gallery.

Solution

Mercari used Compose's AndroidView to integrate traditional Views for gesture handling on the listing form. This gave them a working solution while they waited for Compose's gesture APIs to mature.

Impact

Once Compose's gesture APIs became available, the team rewrote the drag gesture component entirely in Compose. This showed how interoperability between Compose and Views let them keep moving forward without being blocked by missing platform features.