# Android App Size at Scale with Project Bonsai

[Grab](https://yomu.fyi/company/grab) · Nguyen Van Minh · Mar 1, 2024

**Type:** Problem & solution

## Summary

Grab launched Project Bonsai to optimize the size of its Android superapp, which encompassed over four million lines of code across 1,500 modules. Because large app sizes negatively impact user acquisition on low-end devices with constrained bandwidth, the engineering team structured its optimization strategy around measurement, reduction, and containment. The team developed App Sizer, a custom CI-integrated tool that tracks binary compositions and module size contributions in Grafana. Initial reductions targeted Java and Kotlin dex files, resolving bloated transitive R classes by upgrading the Android Gradle Plugin to eliminate overly broad R8 retention rules. These initiatives achieved a 26% reduction in app download size while simultaneously decreasing overall disk footprint.

## Context

The Grab superapp contained over 4 million lines of code and hundreds of third-party libraries, resulting in a large application size that hindered user acquisition and performance on low-end devices with limited storage and bandwidth.

## Approach / What changed

Grab implemented Project Bonsai using a three-pillar framework of measurement, reduction, and containment, developing a custom binary analytics tool called App Sizer and updating the Android Gradle Plugin to allow R8 to strip unused R class fields.

## Takeaways

- Google research revealed that every 6MB increase in APK file size results in a 1% decrease in app install conversion rates.
- Grab created a custom binary analysis tool named App Sizer to monitor device-specific download sizes, team contributions, and third-party library footprints via Grafana dashboards.
- Transitive R class references across more than 1,500 modules bloated dex files because default R8 rules in Android Gradle Plugin 4.0 preserved all static R class member fields.

**Tags:** [Android](https://yomu.fyi/topic/android), [CI/CD](https://yomu.fyi/topic/ci-cd), [Monitoring](https://yomu.fyi/topic/monitoring), [Performance](https://yomu.fyi/topic/performance)

[Read original post](https://engineering.grab.com/project-bonsai)
