## TL;DR

Espresso cannot see the view because it has not appeared yet or the matcher is wrong. Register idling resources for async work, fix the matcher with Layout Inspector, and avoid sleep().

## Error

```text
androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id "submit"
```

## Steps

1. Check the view hierarchy dump in the error; is the view there at all? Expected: present means timing, absent means matcher or navigation.
2. For timing, register an IdlingResource for the async work (network, DB). Expected: Espresso waits properly.
3. For matcher issues, verify with Layout Inspector: the exact id, text, and hierarchy. Expected: the correct matcher.
4. Replace any `Thread.sleep()` with idling resources or `isDisplayed()` waits. Expected: no fixed sleeps.
5. Re-run. Expected: green.

## When to use

- `NoMatchingViewException` in Espresso.
- Async-heavy screens.

## When not to use

- Appium tests (different framework).
- Views that genuinely do not exist (navigation bug).

## Tool compatibility

- Espresso 3.x; AndroidX Test.

## Variant phrasings

### Espresso view not found

The short form; idling resources first.

### NoMatchingViewException fix

The exception name; matcher vs timing.

## Why it happens

Espresso syncs on the UI thread but not on your app's background work. Without idling resources, it checks too early.

## Edge cases

- Animations keep the UI thread busy; disable them in tests.
- WebViews need separate handling; Espresso-Web exists for that.
- Custom idling resources must be unregistered to avoid leaks.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_1AP1L0c5GyjBJbWAJ5gWuA
