Email copiado — support@tuurt.com
Cargando experiencia
android · November 14, 2026 · 7 min

Modularizing a large Android app in Gradle: by feature, not by layer

When incremental builds start slowing the whole team down, more cache is not the fix: splitting the project into feature-based Gradle modules is. We cover why modularizing by technical layer is the most common trap and how to get out of it.

By Tuurt Team

Modularizing a large Android app in Gradle: by feature, not by layer

There is a recognizable moment in the life of almost any Android app that grows past a certain size: someone changes a single line in a ViewModel, hits "Run", and sits there watching Gradle's progress bar recompile modules that have nothing to do with what they just touched. Once that moment starts repeating several times an hour for every developer on the team, the cost stops being an individual annoyance and becomes team-wide time spent waiting on the compiler. The usual answer is the same everywhere: modularize. The problem is that modularizing badly looks a lot like modularizing well for the first few months, and the difference only becomes visible once the team has grown too large to undo it cheaply.

Why a monolithic project gets slow

An Android project with no modules is, as far as Gradle is concerned, a single compilation unit. Any change to any file invalidates the task graph for the whole project, and Gradle has to recompile and rerun annotation processing (KSP, Hilt, Room) over the entire codebase, even when the real change only affects one screen. Kotlin's incremental compilation helps, but it has a limit: if the modified file is part of a public API that other classes consume — an interface, an exposed data class, a repository method — the compiler has to assume every consumer of that API might also be affected, and recompiles in cascade.

Modularizing breaks that single compilation unit into smaller pieces Gradle can treat independently. If the feature-profile module doesn't depend on feature-payments, a change inside feature-payments doesn't force Gradle to touch feature-profile at all. The win isn't that each module compiles faster in absolute terms; it's that most day-to-day changes only invalidate one small module instead of the entire app.

The most common mistake: modularizing by technical layer

When a team decides to modularize for the first time, the most intuitive split is usually technical: a :data module with repositories and data sources, a :domain module with use cases, a :ui module with screens. It looks clean on an architecture diagram, and it does map reasonably well onto Clean Architecture's separation of responsibilities at the class level.

// settings.gradle.kts — modularizing by layer
include(":app")
include(":data")
include(":domain")
include(":ui")

The problem shows up as soon as the team grows past two or three people working in parallel. Almost any new feature needs to touch all three layers: add a use case in :domain, expose a new method in :data, build the screen in :ui. That means developers working on completely different features end up editing the same :domain module, or the same :data module, almost every day. From Gradle's point of view this barely improves on the monolith: if two features share the :ui module, a change to feature A's screen still invalidates the build for feature B's screen, because both live in the same module. And from a version-control point of view, the same interface file in :domain becomes the most frequent merge-conflict hotspot in the repo.

Modularizing by feature: each vertical gets its own module

The alternative is to split by feature, not by layer: each module contains its own UI, its own domain logic and its own data access, scoped to that one piece of functionality.

// settings.gradle.kts — modularizing by feature
include(":app")
include(":core:network")
include(":core:design-system")
include(":feature:profile")
include(":feature:payments")
include(":feature:notifications")

Each :feature:* module depends on whichever :core:* modules it needs — networking, local database, shared UI components — but never on another :feature:* module. If feature:payments needs to show data from the user's profile, it doesn't depend directly on feature:profile; that data is exposed through a shared :core module, or passed as a navigation argument, never as a direct dependency between two features.

// feature/payments/build.gradle.kts
plugins {
    id("com.android.library")
    id("org.jetbrains.kotlin.android")
}

dependencies {
    implementation(project(":core:network"))
    implementation(project(":core:design-system"))
    // Never: implementation(project(":feature:profile"))
}

With this structure, a change inside feature:payments invalidates the build for that module and for :app (which assembles every feature), but leaves feature:profile and feature:notifications untouched. Two developers working on different features almost never touch the same file, which also cuts down merge conflicts — though that's a side effect of the design, not its main goal.

The real limit: the dependency graph, not the module count

Having lots of modules isn't enough if the dependency graph between them stays dense. A common mistake when migrating from layers to features is leaving behind a shared :domain or :common module that every feature keeps importing "to avoid duplicating models." If that module keeps changing as often as before — because that's still where any class two features need to share ends up living — the team recreates the same bottleneck it had with the layered architecture, just under a different name.

The rule we apply is that a shared :core module should only contain what is genuinely stable: HTTP clients, visual design-system components, utilities with no feature-specific business logic. The moment a data type represents a business rule belonging to one specific feature — an order's status, a notification's configuration — that class belongs in that feature's module, even if it means another feature has to request that information through a published interface instead of importing it directly.

Gradle configuration cache and project isolation

Besides cutting compilation work, modularizing by feature also makes it possible to get real value out of two Gradle mechanisms built exactly for this scenario. The configuration cache keeps Gradle from re-evaluating every module's build scripts on each run when nothing relevant changed; with a dense dependency graph between modules, any change to one build.gradle.kts invalidates that cache for the whole subtree depending on it, so the real payoff of the configuration cache grows in step with how sparse the dependency graph becomes. Project isolation, still evolving in recent Gradle versions, goes a step further: it aims to guarantee that one module cannot reach into another module's configuration state during the build, which is only workable if the modules were designed to be independent from the start. Turning these options on over a layered modularization, with a :domain module everyone imports, delivers almost no gain, because the graph is still, in practice, a single coupled unit.

What we got wrong the first time

On a project we migrated from a layered architecture to a feature-based one, the first attempt was to move classes file by file, screen by screen, while keeping the original :domain module as it was, just renamed to :core:domain. Incremental build time improved, but less than expected, and the module kept being a frequent merge-conflict spot. Looking at what it actually contained, we found that more than half the classes in there were use cases specific to a single feature, which different developers kept editing daily simply because there was no other natural place to put them.

The fix took longer than the initial migration: going through each use case one by one, deciding which feature it really belonged to, and moving it into the right module, leaving :core:domain with only the handful of interfaces genuinely used by more than one feature at a time. Only after that second pass did incremental build time drop noticeably, and merge conflicts in that shared module stopped being a daily problem. The lesson wasn't "modularize by feature" — we already knew that going in. It was that renaming a shared module without checking what it actually holds doesn't count as modularizing; it just moves the same bottleneck under a new name.

What we check before signing off on a modularization

Before approving a module structure, we confirm that no :feature module depends directly on another :feature module; all communication between features goes through a shared :core module or through :app's navigation graph. We check that every class inside a shared :core module is genuinely stable and used by more than one feature, not just a convenient place to drop something nobody knew how to classify. And we measure the real impact by asking two or three developers to make typical day-to-day changes in their own features and comparing how many modules each change invalidates: if a change inside a single screen still triggers a rebuild of half the project, the modularization still isn't solving the problem it set out to solve.

android gradle architecture kotlin
← Back to blog