OLX Sahil Jain May 31, 2022

Scaling Android Apps with Gradle Build Types and Product Flavors

M2 Related OWASP risk: Inadequate Supply Chain Security Learn more →

Article Summary

Sahil Jain from OLX reveals how they manage multiple market versions of their Android app without maintaining separate codebases. The secret? Strategic use of Gradle's build configuration.

OLX operates across multiple markets, each with unique feature requirements. Their Android team needed a scalable way to handle different app versions, environments, and feature flags while keeping the codebase maintainable. This article breaks down their Gradle configuration strategy.

Key Takeaways

Critical Insight

OLX scales their Android app across multiple markets by leveraging Gradle build types and product flavors to configure different app versions without code duplication.

Part 2 of this series dives into how OLX uses source sets to further organize code per build variant (hint: it gets even more powerful).

About This Article

Problem

OLX operates in multiple markets, and each one needs different features and settings. Managing separate app versions while keeping a single codebase without duplicating code is difficult.

Solution

Sahil Jain's team used Gradle build types (debug, release, staging) with initWith property inheritance. They added product flavors like WithAdsEnabled to override buildConfigField and resValue properties for each market variant.

Impact

OLX can now publish different app versions to PlayStore with unique applicationIdSuffixes and feature flags. The codebase stays flexible and readable across all market configurations.