Scaling Android Apps with Gradle: Different Source Sets (Part 2)
Article Summary
OLX Engineering scaled their Android app across multiple markets without creating code chaos. Here's how they used Gradle source sets to keep things clean.
This is Part 2 of OLX's series on scaling Android apps with Gradle. While Part 1 covered build types and product flavors, this deep dive shows how different source sets let you compile only what each variant needs.
Key Takeaways
- Source sets follow strict priority: build variant > build type > product flavor > main
- Debug builds include LeakCanary and Chucker; release builds get empty placeholder methods
- Firebase In-App Messaging ships only to specific flavors using dedicated source sets
- Flavored manifests override the base Application class with tools:replace attribute
- Duplicate Java class names across source sets trigger compile errors
Critical Insight
Gradle source sets let you organize code by build variant, compiling only what's needed while maintaining flexibility without maintenance overhead.