Short answer: for most modern Android apps, use MVVM with a repository layer, ideally following Google’s recommended UI, domain and data layers. Move to MVI if you want strict one-way state, and add Clean Architecture layers when the app and team grow large. MVC and MVP are mostly found in older View-based code.
This guide explains each architecture, shows where it fits, and lists the design patterns you will meet in Android projects.
Why architecture matters
- Code is easier to read and change when each class has one job.
- Business logic can be unit tested without running the app.
- Screens survive rotation and process changes more predictably.
- Teams can work on separate features with fewer conflicts.
MVC (Model-View-Controller)
The Model holds data, the View displays it and the Controller connects them. In Android, Activities and Fragments often end up acting as both View and Controller, so they grow large and are hard to test. You will mostly see MVC in older apps.
MVP (Model-View-Presenter)
The Presenter holds the logic and updates the View through an interface. The View becomes passive, which makes the logic testable, but you write many interfaces and the Presenter must be managed carefully to avoid leaks and lifecycle bugs.
interface LoginView {
fun showLoading()
fun showError(message: String)
}
class LoginPresenter(private val view: LoginView) {
fun login(user: String, pass: String) {
view.showLoading()
// call repository, then update the view
}
}
MVVM (Model-View-ViewModel)
The ViewModel exposes UI state, and the View observes it. The ViewModel does not hold a reference to the View, which avoids many lifecycle problems and survives configuration changes. This is the most common pattern in modern Android and fits naturally with Jetpack Compose. See our full MVVM tutorial with Kotlin and Compose.
class LoginViewModel : ViewModel() {
private val _uiState = MutableStateFlow(LoginUiState())
val uiState: StateFlow<LoginUiState> = _uiState.asStateFlow()
fun onLoginClick(user: String, pass: String) { /* ... */ }
}
data class LoginUiState(
val isLoading: Boolean = false,
val error: String? = null
)
MVI (Model-View-Intent)
MVI keeps all screen state in one immutable object. The View sends user actions (intents or events), a reducer or ViewModel produces a new state, and the View renders it. This makes state changes predictable and easy to log and test, at the cost of more boilerplate.
sealed interface LoginEvent {
data class UserChanged(val value: String) : LoginEvent
data object SubmitClicked : LoginEvent
}
Clean Architecture
Clean Architecture organizes code into layers with a strict dependency rule: outer layers depend on inner layers, never the reverse.
- Presentation (UI): composables or Activities and ViewModels.
- Domain: business rules and use cases, written in plain Kotlin with no Android dependencies.
- Data: repositories, network and database implementations.
It works well for large apps and teams. For small apps, a full domain layer can be extra work, so add use cases only where they remove duplication or hold real business rules.
Which architecture should you choose?
| Situation | Recommendation |
|---|---|
| New Compose app, small or medium size | MVVM with a repository |
| Complex screens with many events | MVVM or MVI with a single UI state |
| Large app, many developers | MVVM or MVI with Clean Architecture layers and modules |
| Legacy app using MVC or MVP | Migrate feature by feature to MVVM |
Common design patterns in Android
- Repository: one class that hides where data comes from (network, database, cache).
- Singleton: one shared instance, such as a database or Retrofit client. Prefer dependency injection over manual singletons.
- Observer: LiveData, Flow and StateFlow let the UI react to data changes.
- Factory: creates objects without exposing creation logic, for example a ViewModel factory.
- Builder: configures complex objects step by step, as in
Retrofit.Builder()orAlertDialog.Builder. - Dependency Injection: classes receive their dependencies instead of creating them. Hilt is the standard tool; see our Dagger Hilt tutorial.
- Adapter: connects data to a UI component, as in RecyclerView adapters.
A Repository example:
class UserRepository(
private val api: UserApi,
private val dao: UserDao
) {
suspend fun getUsers(): List<User> {
return try {
val remote = api.getUsers()
dao.insertAll(remote)
remote
} catch (e: IOException) {
dao.getAll() // fall back to cached data when offline
}
}
}
FAQ
What is the best architecture for Android?
MVVM with a repository, following Google’s recommended layers, is the best default for most apps. Add MVI or Clean Architecture if complexity requires it.
What is the difference between MVP and MVVM?
In MVP the Presenter updates the View directly. In MVVM the ViewModel exposes state that the View observes, so there is no direct reference to the View.
Is Clean Architecture required?
No. It helps large and long-lived projects. Small apps can stay simpler with a UI layer and a data layer.
Do I need MVVM with Jetpack Compose?
Compose does not force an architecture, but ViewModel with state hoisting is the officially recommended approach.
Next, read about Jetpack Compose and the Android tutorials for beginners.