Design Android build variants for Multi-Tenant
Article Summary
Piyal Madushanka from PickMe Engineering tackles a problem every scaling mobile team faces: how do you manage multiple regional apps without drowning in build configuration chaos?
When your Android app needs to serve different regions (tenants) with separate dev, staging, and production environments, the naive approach breaks down fast. This article presents a scalable architecture using Android's flavor dimensions to manage multi-tenant apps from a single codebase.
Key Takeaways
- Use two flavor dimensions: tenant and environment for clean separation
- Each tenant gets unique app IDs like com.example.test.tenant1
- Environment suffixes stack: com.example.test.tenant1.development for testing
- Adding new regions requires zero changes to environment configurations
- Single codebase generates all tenant and environment combinations
By structuring product flavors with separate tenant and environment dimensions, you can scale from one app to dozens of regional variants without build script complexity spiraling out of control.
About This Article
PickMe needed to generate multiple Android builds with unique application IDs and build-time configurations for different regions. They wanted to do this while keeping a single codebase, since managing separate codebases would become increasingly complex as they added more tenants.
Piyal Madushanka set up two flavor dimensions in the Android build script. One dimension handled tenants, and the other handled environments. This let each tenant have its own dev, staging, and production variants without needing to change environment configurations.
Adding new regions now just means creating new tenant flavors. The environment flavor logic stays untouched. This makes it possible to generate multi-tenant app variants from one repository for dozens of regional builds without extra work.