Senior and mid-level Android interviews rarely stop at syntax. Sooner or later you get "walk me through the architecture of your last app" or "design the offline mode for this feature". There is no single correct answer, but there are answers that show you understand trade-offs and answers that just list buzzwords. Here are the architecture questions I see most often, with answers grounded in Google's official app architecture guidance and in how real apps are built.
This article assumes you know coroutines and Flow. If not, read the coroutines and Flow interview questions first.
Why architecture
1. Why does an Android app need an architecture at all?
Android components (Activities, Fragments) are created and destroyed by the system: rotations, process death, multi-window. If data and logic live inside them, they are lost or duplicated and become impossible to test. An architecture separates concerns so that UI code only displays state, business logic is testable without a device, and data sources can change without rewriting screens.
2. What are the main principles in Google's architecture guidance?
Separation of concerns, driving UI from data models (ideally persistent ones), a single source of truth for each piece of data, and unidirectional data flow. Saying these four clearly is a strong opening.
3. Describe the recommended layers.
- UI layer: UI elements (composables or Views) plus state holders (ViewModels) that produce UI state.
- Domain layer (optional): use cases that encapsulate business logic reused by several ViewModels.
- Data layer: repositories that expose data and contain data logic, backed by data sources (Retrofit API, Room database, DataStore).
Dependencies point inward: UI depends on domain or data; data depends on nothing in the UI.
MVVM
4. Explain MVVM on Android.
Model: the data and domain layers. View: the Activity, Fragment or composable that renders state and forwards user actions. ViewModel: holds and exposes UI state, survives configuration changes, and calls into the data layer. The View observes the ViewModel; the ViewModel never holds a reference to the View.
data class NotesUiState(
val isLoading: Boolean = true,
val notes: List<Note> = emptyList(),
val errorMessage: String? = null,
)
class NotesViewModel(private val repo: NotesRepository) : ViewModel() {
val uiState: StateFlow<NotesUiState> = repo.observeNotes()
.map { NotesUiState(isLoading = false, notes = it) }
.catch { emit(NotesUiState(isLoading = false, errorMessage = it.message)) }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), NotesUiState())
fun delete(id: Long) {
viewModelScope.launch { repo.delete(id) }
}
}
5. Why must a ViewModel never hold a reference to a View, Activity or Context?
The ViewModel outlives the Activity across rotations. Holding the old Activity leaks it and everything it references. If you need an application context, use AndroidViewModel sparingly or, better, inject a class that wraps the context-dependent work.
6. How does a ViewModel survive rotation, and does it survive process death?
It is stored in the ViewModelStore of the Activity or navigation back stack entry, which is retained across configuration changes. It does not survive process death. For small pieces of state that must (a search query, a selected tab), use SavedStateHandle. Durable data belongs in a database.
7. One UiState object or several StateFlows?
A single immutable UiState per screen is easier to reason about: one source of truth, consistent snapshots, easy to test. Separate flows can go out of sync (loading = false but data not yet set). For complex screens, combine several sources with combine into one state.
MVI
8. What is MVI?
Model-View-Intent. The user's actions are modelled as intents (or actions/events), the ViewModel processes them, and a reducer function produces a new immutable state from the old state and the result. The View renders state and emits intents; nothing else.
sealed interface CounterAction {
data object Increment : CounterAction
data object Reset : CounterAction
}
data class CounterState(val count: Int = 0)
class CounterViewModel : ViewModel() {
private val _state = MutableStateFlow(CounterState())
val state: StateFlow<CounterState> = _state.asStateFlow()
fun onAction(action: CounterAction) {
_state.update { current ->
when (action) {
CounterAction.Increment -> current.copy(count = current.count + 1)
CounterAction.Reset -> CounterState()
}
}
}
}
MutableStateFlow.update applies the change atomically, which matters when several coroutines update state.
9. MVVM vs MVI: which would you choose?
A good answer is honest: modern MVVM with a single UiState and unidirectional data flow is already most of MVI. MVI adds a formal action type and reducer, which helps on complex screens with many interacting events and makes logging or replaying state changes easy. The cost is boilerplate. Choose by screen complexity and team convention, and stay consistent across the codebase.
10. How do you handle side effects in MVI, like navigation or toasts?
Either as part of the state (a nullable message field the UI clears after showing it, which Google recommends) or as a separate effect stream, often a Channel exposed as a Flow. Explain the trade-off: state survives rotation; a channel delivers exactly once but needs careful collection.
Data layer
11. What is a repository and what goes in it?
The single entry point to a type of data. It decides where data comes from (network, database, memory cache), resolves conflicts, and exposes it as suspend functions for one-shot operations and Flows for data that changes over time. ViewModels should not know whether data came from Retrofit or Room.
12. How would you design an offline-first feature?
Make the local database the source of truth. The UI observes a Room Flow. A refresh fetches from the network and writes to the database; the UI updates automatically because it observes the database. Writes are saved locally first, then synced, often with WorkManager so they survive app restarts and retry with backoff when the device is back online. Mention conflict resolution (last write wins, server wins, or merge) as a design decision to agree with the team.
class ArticlesRepository(
private val dao: ArticleDao,
private val api: ArticleApi,
) {
fun observeArticles(): Flow<List<Article>> =
dao.observeAll().map { rows -> rows.map { it.toDomain() } }
suspend fun refresh() {
val remote = api.fetchArticles()
dao.upsertAll(remote.map { it.toEntity() })
}
}
13. Why map between network models, database entities and domain models?
Each layer changes for different reasons. An API field rename should not ripple into your UI. Separate models also keep annotations (@SerialName, @Entity) out of your domain code. For a tiny app this can be overkill; say that you would start simple and split models once they diverge.
Clean architecture and the domain layer
14. What is clean architecture in an Android context?
Robert C. Martin's idea of concentric layers where dependencies only point inward toward business rules. On Android it usually means presentation (UI and ViewModels), domain (use cases, domain models, repository interfaces) and data (repository implementations and data sources). The domain layer is pure Kotlin with no Android dependencies, so it is fast to test.
15. What is a use case?
A class that does one piece of business logic, usually exposing a single operator fun invoke:
class GetVisibleTasksUseCase(
private val tasks: TaskRepository,
private val settings: SettingsRepository,
) {
operator fun invoke(): Flow<List<Task>> =
combine(tasks.observeAll(), settings.observeHideCompleted()) { all, hide ->
if (hide) all.filterNot { it.isDone } else all
}
}
16. Is a domain layer always needed?
No, and Google's guidance marks it optional. Add it when logic is reused across ViewModels or is complex enough to deserve its own tests. A use case that only calls repository.getX() adds a file without adding value. Interviewers like candidates who can say "it depends" and then explain what it depends on.
17. What is the dependency rule, and how do repository interfaces help?
Inner layers must not know about outer layers. The domain layer defines a TaskRepository interface; the data layer implements it. That inverts the dependency: domain does not depend on Room or Retrofit, and tests can provide a fake repository.
Dependency injection
18. Why use dependency injection?
Classes receive their dependencies instead of creating them, so you can swap implementations (fakes in tests, different data sources per build type), control lifetimes and avoid hidden global state. Constructor injection is the default.
19. How does Hilt work at a high level?
Hilt is built on Dagger and generates the dependency graph at compile time. You annotate the Application with @HiltAndroidApp, entry points with @AndroidEntryPoint, ViewModels with @HiltViewModel and an @Inject constructor, and provide interfaces or third-party objects through @Module classes installed in components such as SingletonComponent.
@HiltViewModel
class NotesViewModel @Inject constructor(
private val repo: NotesRepository,
) : ViewModel()
@Module
@InstallIn(SingletonComponent::class)
abstract class DataModule {
@Binds
abstract fun bindNotesRepository(impl: OfflineFirstNotesRepository): NotesRepository
}
Know the alternatives by name: Koin (a runtime service locator style library, popular in Kotlin Multiplatform) and manual DI for small apps.
20. What is the difference between @Binds and @Provides?
@Binds maps an interface to an implementation that Hilt can already construct; it is abstract and generates less code. @Provides is a function that builds the object yourself, needed for third-party classes like a Retrofit instance.
Scaling up
21. Why modularise an Android app?
Faster incremental builds, clear ownership, enforced boundaries (a feature module cannot reach into another's internals) and the option of Play Feature Delivery. A common layout is app, feature:* modules, and core:* modules (data, database, network, design system, model). Google's Now in Android sample is a good public reference to cite.
22. How do you test each layer?
- Domain and data: plain JVM unit tests with fakes, plus
runTestfor coroutines. - ViewModels: unit tests that feed actions and assert
UiStateemissions, withDispatchers.setMain. - Room: instrumented or Robolectric tests with an in-memory database.
- UI: Compose UI tests on stateless screens; a few end-to-end tests for critical flows.
Prefer fakes over mocks for repositories; they are less brittle.
23. Design question: how would you architect a news feed with pagination, offline support and pull to refresh?
Structure your answer: Room as the source of truth; Paging 3 with a RemoteMediator to load pages from the API into the database; the ViewModel exposes Flow<PagingData<Article>> cached in viewModelScope; the UI uses collectAsLazyPagingItems() in a LazyColumn with item keys; pull to refresh calls refresh(); errors appear through the paging load states. Then mention what you would measure and what you would leave out of version one.
The meta-answer
Architecture questions test judgment. Name the principle, show a small piece of code, and say what you would not do in a small app. That combination reads as experience.
Pair this with the Jetpack Compose interview questions, because most architecture discussions end in how the UI consumes state.
Build it, do not just read it
In our Android training in Chennai, participants build an app with a ViewModel, repository, Room and Hilt, so these answers come from code they have written. Kotlin-first learners can start with Kotlin training. See all programs.
K P Ranjith Kumar is a former Google Certified Associate Android Developer and the founder of TechManifester. He has trained Android developers and teams for 12+ years, and founded AndroidManifester (now TechManifester) in Chennai in 2016.