AceMobileInterview

Interview guides / android

Crashy item list: Android Interview Question

Crashy item list interview question with a clear example answer for Android engineers. Practice with AceMobileInterview.

This is a common Android interview topic: Crashy item list.

Below is a concise answer you can adapt in a real interview, then go deeper in the full AceMobileInterview track.

  1. 1.Swipe-delete or empty list can crash detail navigation. Fix unsafe indexes/nulls (≈30–45 min).

    ## Scenario List/detail crashes after delete and when empty. ## How to investigate - Exception breakpoint / Logcat stack - Delete last item; tap quickly during animation - Find `list[index]` and `!!` ## Planted bug 1: Stale index click **Symptom:** `IndexOutOfBoundsException` **Root cause:** Click listener captures index; list mutates before navigation **Fix:** Pass item `id`; look up in the current snapshot ## Planted bug 2: Unsafe `!!` on args **Symptom:** NPE when args missing **Root cause:** `requireArguments().getString("id")!!` **Fix:** Null-check; pop back; show empty state ## Planted bug 3: Empty list assumption **Symptom:** Crash in header/binder **Root cause:** Code assumes `items.first()` **Fix:** Guard empty; proper empty UI ## Optimization tips - Prefer immutable list snapshots in UI state - Key LazyColumn items by id ## What to say in the interview - How the stack pointed to the listener capture - Regression cases you’d add

Keep going with AceMobileInterview

Reading helps. Timed practice locks it in. Jump into the interactive track for algorithms with LeetCode links, studio projects, debugging zips, and mobile system design.

iOS trackAndroid trackMore guides