Core/Core-Impl Pattern: Build-Performance Superpower of DI & Gradle
Article Summary
Your modular Android app is building like a monolith. One shared :core module is killing your build times, even when you change a single private implementation detail.
Pavan Varma breaks down the Core/Core-Impl pattern for Android projects. This architectural approach uses dependency injection to separate interface contracts from heavy implementations, unlocking true parallel compilation in Gradle.
Key Takeaways
- Clean builds dropped from 15 min to 10 min (33% faster)
- Split :core into lightweight interfaces and heavy :core-impl implementation
- Features compile in parallel since they never depend on :core-impl
- Changes to common code no longer trigger feature module recompilation
- Works seamlessly with Hilt for dependency injection
Critical Insight
By separating what features need (interfaces) from how it's implemented, teams achieve dramatic build speed improvements without throwing hardware at the problem.