Android Developer Interview Questions and Answers
Last updated 2026-11-19
Modern Android interviews are about Kotlin, Jetpack Compose and the architecture components, with the older View system and Java still appearing in maintenance work. Interviewers ask how state survives configuration changes, how coroutines are scoped to lifecycles, how to avoid leaking an Activity and how you would structure a screen with a ViewModel and a repository.
This page covers those questions with Kotlin code. It assumes current recommended practice: Compose for UI, ViewModel with StateFlow, Room for local data and Hilt for injection. For general preparation, the process in how to crack a take-home assignment helps, since many mobile hiring loops include a small app. Cross-platform alternatives are covered on the Flutter and React Native pages.
| Language | Kotlin, with Java for older code |
|---|---|
| Core topics | Lifecycle, Compose, ViewModel, coroutines and Flow, Room, DI, performance |
| Questions here | 17 |
What the take-home or live task usually is
A common task is a list and detail app that fetches from a public API, caches in Room and handles loading, error and empty states. Reviewers look at architecture, separation of UI and data layers, handling of rotation, null safety, tests for the ViewModel and basic accessibility such as content descriptions.
Habits to demonstrate
- Hold UI state in a single immutable data class exposed as StateFlow.
- Launch coroutines from viewModelScope or lifecycle-aware scopes, never GlobalScope.
- Collect flows in Compose with collectAsStateWithLifecycle.
- Keep Context out of ViewModels unless it is the application context.
- Write one unit test for a ViewModel using a test dispatcher.
Android Developer Interview Questions and Answers: questions with worked answers
1 Describe the Activity lifecycle.
easyonCreate sets up the Activity, onStart makes it visible, onResume gives it focus and interaction. Leaving reverses it: onPause when partially covered, onStop when no longer visible, onDestroy when finishing or being destroyed by the system. Rotation destroys and recreates the Activity by default, so state must be stored in a ViewModel, rememberSaveable or saved instance state. Do heavy work outside the lifecycle callbacks.
2 What is the difference between an Activity, a Fragment and a Composable?
easyAn Activity is an entry point that hosts UI and has its own lifecycle. A Fragment is a reusable part of UI with its own lifecycle, hosted in an Activity. A Composable is a function that describes UI, with no lifecycle of its own beyond entering and leaving composition. Modern apps often use a single Activity and Compose navigation.
3 Explain Kotlin null safety.
easyTypes are non-null by default, and String? allows null. The compiler forces you to handle null with safe call ?., the Elvis operator ?:, a smart cast after a check, or let. The not-null assertion !! throws if null and should be avoided. Platform types from Java code are unchecked, so annotate or wrap them at the boundary.
kotlinval name: String? = user?.profile?.displayName val shown = name ?: "Guest" name?.let { println(it.length) }4 How does state work in Jetpack Compose, and what is recomposition?
mediumCompose re-runs composable functions when state they read changes, which is recomposition, and skips composables whose inputs are unchanged. remember keeps a value across recompositions, mutableStateOf makes it observable, and rememberSaveable also survives configuration changes and process death for simple types. Hoist state upward so composables stay stateless and testable.
kotlin@Composable fun Counter() { var count by rememberSaveable { mutableIntStateOf(0) } Button(onClick = { count++ }) { Text("Clicked $count times") } }5 How do you structure a screen with ViewModel and StateFlow?
mediumThe ViewModel owns UI state as a StateFlow of an immutable data class, updated from coroutines in viewModelScope, and exposes events as functions. It survives configuration changes and has no reference to Views or an Activity Context. The composable collects state with collectAsStateWithLifecycle, which stops collecting when the app is in the background.
kotlindata class UiState(val loading: Boolean = true, val items: List<Item> = emptyList(), val error: String? = null) class ListViewModel(private val repo: ItemRepository) : ViewModel() { private val _state = MutableStateFlow(UiState()) val state: StateFlow<UiState> = _state.asStateFlow() init { viewModelScope.launch { runCatching { repo.load() } .onSuccess { items -> _state.update { it.copy(loading = false, items = items) } } .onFailure { e -> _state.update { it.copy(loading = false, error = e.message) } } } } }6 Explain coroutines, dispatchers and structured concurrency.
mediumA coroutine is a lightweight suspendable computation. Dispatchers choose the thread: Main for UI, IO for blocking I/O and Default for CPU work. Structured concurrency ties a coroutine to a scope, so cancelling the scope cancels its children and a failing child cancels its siblings. Use coroutineScope or supervisorScope, and switch dispatcher with withContext, not by launching on a new one.
kotlinsuspend fun loadBoth(): Pair<User, List<Post>> = coroutineScope { val user = async { api.user() } val posts = async { api.posts() } user.await() to posts.await() }7 What is the difference between Flow, StateFlow and SharedFlow?
mediumA plain Flow is cold: it runs its producer for each collector. StateFlow is hot, always holds a current value, replays it to new collectors and conflates equal values, which makes it right for UI state. SharedFlow is hot with configurable replay and no initial value, good for one-off events, though events are often better modelled as state to avoid losing them. Use stateIn or shareIn to turn a cold flow into a hot one.
8 How does Room work?
mediumRoom is an abstraction over SQLite. You annotate entities, define DAOs with SQL queries verified at compile time, and declare a database class. DAOs can return suspend results or Flow, which re-emits when the table changes. Provide schema migrations with Migration objects or auto-migrations, and never allow main-thread queries. Export the schema to test migrations.
kotlin@Entity data class Note(@PrimaryKey(autoGenerate = true) val id: Long = 0, val text: String) @Dao interface NoteDao { @Query("SELECT * FROM Note ORDER BY id DESC") fun observeAll(): Flow<List<Note>> @Insert suspend fun insert(note: Note) }9 How does dependency injection with Hilt work?
mediumHilt is built on Dagger and generates the component hierarchy for you. Annotate the Application with @HiltAndroidApp, entry points such as Activities with @AndroidEntryPoint, ViewModels with @HiltViewModel and constructors with @Inject. Provide classes you do not own in a @Module with @Provides, scoped with @InstallIn. DI makes classes testable because you can substitute fakes.
10 What causes an ANR and how do you avoid it?
mediumApplication Not Responding appears when the main thread is blocked, for example for about five seconds without handling an input event. Causes are disk or network I/O, heavy computation, long locks and slow broadcast receivers on the main thread. Move work to coroutines on the IO or Default dispatcher, use StrictMode in debug builds, and check traces with Android Studio and the Play Console vitals.
11 How do you prevent memory leaks in Android?
mediumA leak happens when a long-lived object holds a reference to a short-lived one, such as a static field, singleton or listener referencing an Activity. Avoid storing Context in static or ViewModel fields, use applicationContext when a long-lived Context is needed, unregister listeners and receivers, cancel coroutines with lifecycle scopes, clear View binding in Fragment onDestroyView and use LeakCanary in debug builds to find them.
12 LazyColumn versus RecyclerView?
mediumLazyColumn composes only the visible items and is the Compose replacement for RecyclerView. Provide stable keys so state is kept when the list changes, and avoid heavy work inside item composables. RecyclerView needs an adapter, ViewHolder and DiffUtil, and still appears in existing apps. Both recycle or skip off-screen work, so keep items cheap and use immutable data to help skipping.
kotlinLazyColumn { items(items = notes, key = { it.id }) { note -> NoteRow(note) } }13 How do you run background work reliably?
mediumUse WorkManager for deferrable, guaranteed work such as syncing or uploading, with constraints like network and charging, and retry with backoff. It survives app restarts and reboots. Use a foreground service for user-visible ongoing work such as music or navigation, with a notification and a declared foreground service type. For work only while the app is open, use coroutines in a lifecycle scope. Exact alarms are restricted on recent Android versions.
14 What are Compose side effects: LaunchedEffect, rememberCoroutineScope, DisposableEffect?
hardComposables should be free of side effects, so Compose provides controlled ones. LaunchedEffect(key) launches a coroutine when it enters composition and restarts when the key changes, cancelling on exit. rememberCoroutineScope gives a scope for launching from event handlers such as clicks. DisposableEffect registers and cleans up resources like listeners. rememberUpdatedState keeps the latest lambda inside a long-running effect.
kotlinLaunchedEffect(userId) { viewModel.load(userId) // restarts only when userId changes } DisposableEffect(lifecycleOwner) { val obs = LifecycleEventObserver { _, e -> /* react */ } lifecycleOwner.lifecycle.addObserver(obs) onDispose { lifecycleOwner.lifecycle.removeObserver(obs) } }15 How do you make Compose performance good?
hardKeep composables small and stateless, pass stable or immutable parameters so Compose can skip them, read state as late as possible, for example in a lambda modifier, and use derivedStateOf when a computed value changes less often than its inputs. Provide keys in lazy lists. Measure with the Layout Inspector recomposition counts and baseline profiles, and test in release builds with R8 enabled, since debug builds are slower.
16 How does the Android process death affect your app and how do you handle it?
hardThe system can kill a background app process to free memory, and when the user returns the Activity is recreated from saved state while ViewModels are gone. Save small state with rememberSaveable or SavedStateHandle in the ViewModel, and keep larger data in a database. Test it with Developer options "Don't keep activities" or adb shell am kill. Never assume a singleton still holds data.
17 What does R8 do and what can go wrong?
hardR8 shrinks, optimises and obfuscates code in release builds, removing unused classes and renaming the rest. Reflection and serialisation libraries break if their classes are renamed or removed, so add keep rules, or use libraries that ship consumer rules. Keep the mapping file to deobfuscate crash traces. Always test the release build, not only debug.
18 How do you test an Android app?
hardUnit-test ViewModels and repositories on the JVM using fakes, coroutines test with a StandardTestDispatcher and Turbine for flows. Test Compose UI with createComposeRule, finding nodes by semantics and test tags. Use instrumented tests on a device or emulator for Room and integration, and Espresso for View-based UI. Keep the pyramid weighted to fast unit tests.
kotlin@Test fun emitsLoadedItems() = runTest { val vm = ListViewModel(FakeRepo(listOf(Item(1)))) advanceUntilIdle() assertEquals(1, vm.state.value.items.size) }19 How do you handle runtime permissions and edge-to-edge on recent Android versions?
hardDangerous permissions such as camera, location and notifications from Android 13 are requested at runtime with the Activity Result API, ideally when the feature is first used and with an explanation if the user denied before. Handle denial gracefully. Apps targeting Android 15 draw edge-to-edge by default, so use window insets to avoid content under system bars.
Frequently asked questions
Should I learn Kotlin or Java for Android interviews?
Kotlin, as it is the recommended language, but be able to read Java because older code and many DSA rounds use it.
Is XML layout knowledge still needed?
Yes for maintaining older apps, but new projects use Jetpack Compose. Know both well enough to compare them.
What architecture do interviewers expect?
A layered approach with UI, ViewModel and repository, unidirectional data flow, dependency injection and a local cache. MVVM or MVI naming is less important than clear separation.
Do Android roles ask DSA?
Often yes at product companies, usually easy to medium problems, alongside Android-specific questions.
Related guides
More in Role-wise Interview Questions by Job and Tech Stack
- Angular Interview Questions and Answers (Angular 18 and Later)
- Ansible Interview Questions and Answers
- API Testing and Postman Interview Questions
- Automation Testing Interview Questions and Answers
- AWS Interview Questions and Answers
- Azure Interview Questions and Answers
- Backend Developer Interview Questions and Answers
- Business Analyst Interview Questions and Answers
- Cloud Engineer Interview Questions and Answers
- Computer Vision Interview Questions and Answers
- Cybersecurity Interview Questions and Answers
- Data Analyst Interview Questions and Answers