ScreenSync MCP guide

Testing Android Navigation 3 with Claude Code and MCP

Test Jetpack Navigation 3 state-driven back stacks, NavDisplay transitions, and ListDetailSceneStrategy adaptive panes on real Android hardware with Claude Code and ScreenSync MCP.

Minimalist 3D architectural render of an Android smartphone displaying stacked translucent glass navigation cards linked by glowing purple fiber-optic lines to a developer laptop in deep navy lighting

Jetpack Navigation 3 (androidx.navigation3) fundamentally changes how Android applications model screen state by replacing the encapsulated NavController graph with a developer-owned SnapshotStateList of serializable NavKey objects and a composable NavDisplay. While that shift makes state transitions transparent in Kotlin code, verifying multi-pane SceneStrategy resolution, EntryDecorator lifecycle scoping, process-death restoration, and real back-gesture animations still fails silently in JVM unit tests. Connecting Claude Code to physical Android hardware through ScreenSync MCP—an Android and browser Model Context Protocol (MCP) server created by EpsolDev—lets an autonomous engineering agent inspect live UI trees, capture screen frames, read Logcat telemetry, and drive real gestures directly against your Navigation 3 runtime.

Key Takeaways

  • State-First Verification: Navigation 3 removes the black-box NavController in favor of a SnapshotStateList back stack, allowing Claude Code to correlate get_ui_hierarchy and get_logcat outputs with exact NavKey pushes and pops.
  • Capture vs. Control Separation: ScreenSync MCP captures frames via Android's MediaProjection API with no root and no ADB (achieving about 94 ms median LAN mirror latency in EpsolDev's tests), while control_tap, control_swipe, and control_type execute over ADB (USB or wireless debugging).
  • 226-Tool Surface: The desktop hub exposes 29 phone and desktop tools (12 control_*, 3 os_*, 14 capture/hub tools) plus 197 web_* browser tools for cross-surface deep-link and web-to-app verification.
  • Adaptive Scene Coverage: Real-device testing catches ListDetailSceneStrategy pane splits, SavedStateNavEntryDecorator omissions, and ViewModelStoreNavEntryDecorator leaks that single-pane Robolectric tests miss.

Why Jetpack Navigation 3 Breaks Traditional UI Test Assumptions

Jetpack Navigation 3 replaces imperative NavController graph traversal with a reactive SnapshotStateList of NavKey objects rendered by NavDisplay. Because developers now own stack mutations, decorators, and adaptive SceneStrategy layouts directly, traditional TestNavHostController assertions no longer apply and real-device integration testing becomes essential.

In Jetpack Navigation 2 (androidx.navigation:navigation-compose), the framework owned the back stack inside NavHostController. Automated tests relied on TestNavHostController to assert currentBackStackEntry?.destination?.route, while Compose UI tests treated navigation as an opaque side effect. In Navigation 3 (androidx.navigation3:navigation3-runtime and androidx.navigation3:navigation3-ui), that ownership flips completely:

  1. You mutate the back stack directly: Pushing a screen means calling backStack.add(ProductDetailKey(sku)), and popping means backStack.removeLastOrNull().
  2. Entries are decoupled from rendering: entryProvider maps each NavKey to a NavEntry, while NavDisplay delegates layout calculation to a SceneStrategy such as SinglePaneSceneStrategy or Material 3 Adaptive's ListDetailSceneStrategy.
  3. State and ViewModel lifetimes live in decorators: Unless you attach SavedStateNavEntryDecorator and ViewModelStoreNavEntryDecorator, popping or rotating an entry silently drops state or retains stale ViewModels across screen transitions.

If your team already uses AI agents for Jetpack Compose UI testing on physical hardware, migrating to Navigation 3 introduces a distinct class of regressions that only appear when real system events hit NavDisplay:

  • Duplicate or non-idempotent key pushes: Rapid double-taps on a physical touchscreen can append two identical NavKey instances to your SnapshotStateList unless your reducer guards transitions against backStack.lastOrNull().
  • Broken adaptive pane transitions: On foldables or tablets, ListDetailSceneStrategy keeps both list and detail panes mounted simultaneously; unit tests on compact viewports miss overlapping touch targets, broken pane headers, and focus-trapping bugs.
  • Silent serialization crashes on process kill: rememberNavBackStack requires @Serializable NavKey classes registered with SavedStateConfiguration on polymorphic sealed hierarchies; missing a serializer only surfaces during actual OS state saving and restoration.
  • Desynchronized predictive back gestures: System edge swipes on Android 14, Android 15, and Android 16 interact with NavDisplay transition specs differently than programmatic removeLastOrNull() button clicks.
  • Window inset and IME clipping during scene swaps: When a detail pane hosts a form with imePadding() inside a multi-pane Scene, keyboard appearance can push primary action buttons off-screen on compact phones while looking normal in previews.
Dimension Jetpack Navigation 2 (NavController) Jetpack Navigation 3 (NavDisplay + NavBackStack) Real-Device MCP Verification Focus
Back Stack Ownership Encapsulated inside NavHostController Developer-owned SnapshotStateList<NavKey> Guard against duplicate pushes from rapid control_tap inputs
Test Double Support TestNavHostController route assertions Direct list assertions in unit tests; UI tree in E2E Correlate get_ui_hierarchy nodes with NavKey log events
Multi-Pane Layouts Custom WindowSizeClass branching inside screens Pluggable SceneStrategy (ListDetailSceneStrategy) Verify single-pane vs. two-pane bounds via get_latest_screenshot
Entry State Scoping Managed implicitly per NavBackStackEntry Explicit entryDecorators (SavedState, ViewModelStore) Validate state survival across rotation and ADB process death
Transition & Back Handling XML/DSL enterTransition on NavHost NavDisplay transitionSpec and onBack lambda Test edge swipes via control_swipe and record with record_screen

Setting Up ScreenSync MCP with Claude Code for Real-Device Navigation 3 Testing

Setting up ScreenSync MCP requires installing the free Android app (Android 7.0 or later) from Google Play, running the Node.js 18+ desktop hub locally, and registering the stdio server with Claude Code. Capture uses MediaProjection without root or ADB, while device control tools operate over ADB.

Before Claude Code can drive your Navigation 3 app on a physical phone or tablet, configure the local bridge between your device and workstation. ScreenSync MCP keeps frame transport local to your LAN rather than routing screens through EpsolDev servers. For full installation instructions and hub downloads, follow the ScreenSync MCP setup guide.

1. Install the Android App and Start the Desktop Hub

  • Install ScreenSync MCP (com.screensync.mcp, version 2.5.7) free from Google Play on any phone or tablet running Android 7.0 or later.
  • Unpack the desktop hub (version 1.14.4) on Windows, macOS, or Linux with Node.js 18+ installed, and start it using start-hub.bat or start-hub.sh. The hub listens on HTTP port 3000 and speaks Model Context Protocol over stdio.
  • Pair the Android app by scanning the hub QR code or using mDNS auto-discovery on your local network, then approve the Android MediaProjection consent dialog when starting a capture session.
  • Enable USB debugging or Android Wireless Debugging in Developer Options so the desktop hub can dispatch touch and text events. Keep the architectural separation clear: screen capture uses Android's MediaProjection API with no root and no ADB, whereas control tools (control_tap, control_swipe, control_type) execute through ADB over USB or wireless debugging.

2. Register ScreenSync MCP in Claude Code or Claude Desktop

Register the local stdio server in Claude Code directly from your Android project root:

claude mcp add screensync node "/path/to/hub/screensync-hub.js"

If you also use Claude Desktop alongside your IDE, add the server entry inside claude_desktop_config.json (Settings > Developer) with your local pairing token:

{
  "mcpServers": {
    "screensync": {
      "command": "node",
      "args": ["/path/to/hub/screensync-hub.js"],
      "env": {
        "SCREEN_SYNC_TOKEN": "your-local-pairing-token"
      }
    }
  }
}

For Cursor or VS Code agent mode, check your client's MCP documentation to point its local stdio server configuration at the same screensync-hub.js entrypoint. Once connected, your AI agent gains access to 226 MCP tools (29 phone and desktop tools—including 12 control_*, 3 os_*, and 14 capture/hub tools—plus *197 `web_browser tools**), **17 prompts**, and **3 resources**. Be transparent in security reviews about data boundaries: live screen frames stream strictly from the phone to the hub on your local network (never to EpsolDev servers; Google Drive fallback is optional), while any screenshot requested by the AI agent viaget_latest_screenshot` is sent to that agent's model provider.

Instrumenting a Navigation 3 Sample for Deterministic AI Verification

Instrumenting a Jetpack Navigation 3 app for AI-driven testing requires combining @Serializable NavKey hierarchies, explicit SavedStateNavEntryDecorator and ViewModelStoreNavEntryDecorator hooks, semantic testTag modifiers, and structured Logcat breadcrumbs so Claude Code can verify back stack mutations and ViewModel lifecycles deterministically on physical Android hardware.

Visual inspection alone cannot tell an AI agent whether your SnapshotStateList pushed a duplicate key or failed to clear a scoped ViewModel. By pairing clean Jetpack Compose semantics with lightweight debug-only logging, you give Claude Code two independent verification channels: the live accessibility node tree via get_ui_hierarchy and runtime lifecycle events via get_logcat.

Below is a production-structured Navigation 3 setup supporting both single-pane phones and adaptive list-detail layouts with explicit SavedStateConfiguration serialization:

package com.example.nav3qa

import android.util.Log
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.material3.adaptive.ExperimentalMaterial3AdaptiveApi
import androidx.compose.material3.adaptive.navigation3.ListDetailSceneStrategy
import androidx.compose.material3.adaptive.navigation3.rememberListDetailSceneStrategy
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.unit.dp
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.lifecycle.viewmodel.navigation3.rememberViewModelStoreNavEntryDecorator
import androidx.navigation3.runtime.NavKey
import androidx.navigation3.runtime.entryProvider
import androidx.navigation3.runtime.rememberNavBackStack
import androidx.navigation3.runtime.rememberSavedStateNavEntryDecorator
import androidx.navigation3.ui.NavDisplay
import androidx.savedstate.serialization.SavedStateConfiguration
import kotlinx.serialization.Serializable
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic

@Serializable
sealed interface CatalogKey : NavKey {
    @Serializable
    data object ProductList : CatalogKey

    @Serializable
    data class ProductDetail(val productId: String) : CatalogKey

    @Serializable
    data class CheckoutReview(val productId: String, val quantity: Int) : CatalogKey
}

val CatalogSavedStateConfig = SavedStateConfiguration {
    serializersModule = SerializersModule {
        polymorphic(NavKey::class) {
            subclass(CatalogKey.ProductList::class, CatalogKey.ProductList.serializer())
            subclass(CatalogKey.ProductDetail::class, CatalogKey.ProductDetail.serializer())
            subclass(CatalogKey.CheckoutReview::class, CatalogKey.CheckoutReview.serializer())
        }
    }
}

class DetailViewModel(private val productId: String) : ViewModel() {
    init {
        Log.d("Nav3QA", "DetailViewModel_INIT id=$productId hash=${hashCode()}")
    }

    override fun onCleared() {
        Log.d("Nav3QA", "DetailViewModel_CLEARED id=$productId hash=${hashCode()}")
        super.onCleared()
    }
}

@OptIn(ExperimentalMaterial3AdaptiveApi::class)
@Composable
fun CatalogNavHost() {
    val backStack = rememberNavBackStack(
        configuration = CatalogSavedStateConfig,
        CatalogKey.ProductList
    )
    val listDetailStrategy = rememberListDetailSceneStrategy<CatalogKey>()

    LaunchedEffect(backStack.toList()) {
        Log.d("Nav3QA", "BACKSTACK_CHANGED size=${backStack.size} keys=${backStack.joinToString()}")
    }

    Box(modifier = Modifier.fillMaxSize().semantics { testTagsAsResourceId = true }) {
        NavDisplay(
            backStack = backStack,
            onBack = { backStack.removeLastOrNull() },
            sceneStrategy = listDetailStrategy,
            entryDecorators = listOf(
                rememberSavedStateNavEntryDecorator(),
                rememberViewModelStoreNavEntryDecorator()
            ),
            entryProvider = entryProvider {
                entry<CatalogKey.ProductList>(
                    metadata = ListDetailSceneStrategy.listPane(
                        detailPlaceholder = {
                            Box(Modifier.fillMaxSize().testTag("nav3_detail_placeholder")) {
                                Text("Select a product to inspect", Modifier.padding(24.dp))
                            }
                        }
                    )
                ) {
                    ProductListPane(
                        modifier = Modifier.testTag("list_pane_root"),
                        selectedProductId = (backStack.lastOrNull() as? CatalogKey.ProductDetail)?.productId,
                        onSelectProduct = { id ->
                            val target = CatalogKey.ProductDetail(id)
                            if (backStack.lastOrNull() != target) {
                                backStack.add(target)
                            }
                        }
                    )
                }

                entry<CatalogKey.ProductDetail>(
                    metadata = ListDetailSceneStrategy.detailPane()
                ) { key ->
                    val vm = viewModel(key = "detail_${key.productId}") {
                        DetailViewModel(key.productId)
                    }
                    ProductDetailPane(
                        modifier = Modifier.testTag("detail_pane_root"),
                        productId = key.productId,
                        onCheckout = { qty ->
                            val next = CatalogKey.CheckoutReview(key.productId, qty)
                            if (backStack.lastOrNull() != next) {
                                backStack.add(next)
                            }
                        },
                        onBack = { backStack.removeLastOrNull() }
                    )
                }

                entry<CatalogKey.CheckoutReview>(
                    metadata = ListDetailSceneStrategy.extraPane()
                ) { key ->
                    CheckoutReviewPane(
                        modifier = Modifier.testTag("extra_pane_root"),
                        productId = key.productId,
                        quantity = key.quantity,
                        onConfirm = {
                            while (backStack.size > 1) {
                                backStack.removeLastOrNull()
                            }
                        }
                    )
                }
            }
        )
    }
}

Three deliberate engineering hooks make this Navigation 3 setup observable by Claude Code:

  1. testTagsAsResourceId = true on the root container: UIAutomator and ScreenSync MCP's get_ui_hierarchy expose Compose testTag values as standard Android resource IDs (list_pane_root, detail_pane_root, nav3_detail_placeholder), giving Claude Code exact element coordinates without fragile OCR guessing.
  2. CatalogSavedStateConfig polymorphic registration: Registering every NavKey subtype in SavedStateConfiguration prevents runtime SerializationException crashes when rememberNavBackStack writes your stack into a Bundle during backgrounding or configuration changes.
  3. BACKSTACK_CHANGED and DetailViewModel_CLEARED Logcat markers: Calling get_logcat after control_tap or control_swipe lets Claude Code verify that DetailViewModel.onCleared() executed when CatalogKey.ProductDetail left the stack—a lifecycle invariant that visual screenshots cannot observe.

Core ScreenSync MCP Workflow: Inspect, Act, Correlate

An effective Claude Code Navigation 3 test loop alternates between structural UI inspection (get_ui_hierarchy), low-latency visual capture via MediaProjection (get_latest_screenshot), ADB-backed input dispatch (control_tap, control_swipe, control_type), and runtime telemetry (get_logcat and record_screen) so every stack push, pop, and pane transition is empirically verified.

Rather than guessing screen coordinates blindly, Claude Code follows a strict observe-act-verify loop grounded in structural node trees. You can read more about this design in why AI agents need the Android UI hierarchy and how ScreenSync MCP captures Android screens.

Navigation 3 Verification Stage ScreenSync MCP Tool(s) Used Transport / Privilege Assertion Target
1. Initial Route & Placeholder Check get_ui_hierarchy, get_latest_screenshot MediaProjection + Hub (No root, no ADB for capture) Confirm list_pane_root rendered; on tablets verify nav3_detail_placeholder
2. Forward Key Push & Idempotency control_tap, get_logcat ADB (USB or Wireless) + Logcat stream Confirm BACKSTACK_CHANGED size=2 with single ProductDetail key
3. Form State Retention Across Transitions control_type, control_tap, get_ui_hierarchy ADB input + Hierarchy inspection Enter quantity, push CheckoutReview, pop back, verify preserved input
4. System Back & Gesture Transitions control_swipe, record_screen ADB gesture injection + MediaProjection video Verify predictive back animation and DetailViewModel_CLEARED in get_logcat
5. Cross-Surface Deep Link Return web_* browser tools + get_ui_hierarchy Chrome/Edge MV3 Extension + Mobile Hub Trigger web auth/handoff link and confirm Navigation 3 stack restores target key

You can prompt Claude Code inside your Android repository using a deterministic verification script:

Using the connected ScreenSync MCP server:
1. Call get_ui_hierarchy and get_latest_screenshot to confirm the app is on CatalogKey.ProductList.
2. Tap the first product item twice in rapid succession using control_tap to test push idempotency.
3. Call get_logcat filtering for "Nav3QA" and confirm BACKSTACK_CHANGED shows size=2 (never size=3).
4. Type quantity "3" using control_type, navigate to CheckoutReview, pop back once, and confirm "3" remains in the hierarchy via SavedStateNavEntryDecorator.
5. Execute an edge-back gesture with control_swipe to return to ProductList and verify DetailViewModel_CLEARED appears in get_logcat.

Because ScreenSync MCP's local mirror delivers about 94 ms median latency on a LAN in EpsolDev's tests, Claude Code can capture post-transition frames immediately after each navigation gesture without waiting seconds for remote cloud emulators to settle.

Testing Adaptive SceneStrategy Panes on Phones, Foldables, and Tablets

Testing Navigation 3 SceneStrategy layouts requires verifying how NavDisplay transitions between SinglePaneSceneStrategy and ListDetailSceneStrategy across compact and expanded window sizes. Claude Code combines live get_ui_hierarchy bounding-box analysis, get_latest_screenshot visual checks, and ADB display-size overrides to validate adaptive panes on physical hardware.

One of Navigation 3's primary architectural advantages is decoupling what keys sit on the back stack from how panes are arranged on the screen. With ListDetailSceneStrategy, a stack of [ProductList, ProductDetail("sku-42")] renders only ProductDetail on a 411dp portrait phone, yet displays ProductList beside ProductDetail on an unfolded foldable or tablet.

Several layout regressions surface specifically at this adaptive boundary:

  • Detail-pane back button traps: On a compact phone, ProductDetail needs a top-bar Back icon that calls backStack.removeLastOrNull(). When rendered side-by-side in ListDetailSceneStrategy, tapping that Back button might unexpectedly clear the detail pane back to the placeholder or exit the activity if onBack does not account for multi-pane visibility.
  • Stale list highlight synchronization: Selecting item A, pushing CheckoutReview into extraPane(), and popping back on a tablet can leave the wrong row highlighted in list_pane_root if selection derives from local component state instead of backStack.
  • Android 16 resizability enforcement: Apps targeting Android 16 (API level 36) cannot lock screen orientation or restrict resizability on large displays, so ListDetailSceneStrategy transitions can trigger dynamically mid-session when a user resizes a window or unfolds hardware.

For broader posture and hinge-angle scenarios, read our guide on testing Android foldables and adaptive layouts with Claude Code. For Navigation 3 scene verification, Claude Code toggles display geometry over ADB while inspecting hierarchy bounds with get_ui_hierarchy:

# Inspect current physical display metrics before changing anything
adb shell wm size
adb shell wm density

# Simulate an expanded tablet/unfolded viewport (e.g., 1600x2560 at 320dpi = 800dp+ width)
adb shell wm size 1600x2560
adb shell wm density 320

# Always restore hardware defaults immediately after verification
adb shell wm size reset
adb shell wm density reset

When Claude Code calls get_ui_hierarchy after resizing, it verifies whether list_pane_root and detail_pane_root coexist in the active node tree with non-overlapping bounds rectangles (such as [0,0][640,2560] and [640,0][1600,2560]), then calls get_latest_screenshot to check divider spacing, safe-area insets, and button truncation.

Verifying Custom SceneStrategy Overlays and Bottom Sheet Entries

Beyond ListDetailSceneStrategy, teams routinely implement custom SceneStrategy classes to render modal sheets, confirmation dialogs, or floating inspector panels on top of an underlying NavEntry. Because overlays sit inside a separate Compose window or popup layer, standard view-matching tests frequently click through an overlay onto the blocked pane beneath it.

To test a custom DialogSceneStrategy with Claude Code:

  1. Trigger the modal NavKey: Dispatch control_tap on the action button that appends your dialog key to backStack.
  2. Verify window layering in get_ui_hierarchy: Confirm the modal surface renders at the top of the accessibility focus order and that underlying list_pane_root buttons are marked non-clickable or obscured by a scrim node.
  3. Test outside-tap and Back dismissal: Use control_tap on the scrim coordinates and verify via get_logcat that BACKSTACK_CHANGED popped the modal NavKey cleanly without mutating the underlying detail route.

Auditing EntryDecorator State Restoration and Process Death

Auditing Navigation 3 EntryDecorator behavior ensures that rememberSaveable UI state survives screen transitions and OS process termination while scoped ViewModels clear promptly upon pop. Combining ADB am kill simulation with ScreenSync MCP's get_ui_hierarchy, get_latest_screenshot, and get_logcat tools exposes serialization gaps immediately.

Because rememberNavBackStack persists your NavKey list through SavedState and Kotlinx Serialization, two subtle failure modes appear frequently in production builds even when unit tests are green:

  1. Missing SavedStateNavEntryDecorator: Passing entryDecorators = listOf(rememberViewModelStoreNavEntryDecorator()) without rememberSavedStateNavEntryDecorator() causes rememberSaveable scroll positions, expanded accordions, and text inputs inside ProductList to reset to defaults as soon as ProductDetail replaces it in a single-pane scene.
  2. Polymorphic serializer gaps under process death: Everything works smoothly while the process stays warm in memory—until Android kills the backgrounded app and tries to deserialize SnapshotStateList<CatalogKey> on cold relaunch. A missing @Serializable annotation or unregistered subclass crashes the app immediately on resume.

Our dedicated guide on testing Android process death with Claude Code covers system-wide SavedStateHandle persistence; for Navigation 3 specifically, Claude Code executes this three-step background-kill sequence over ADB:

# 1. Background the app so Android persists the NavBackStack SavedState bundle
adb shell input keyevent KEYCODE_HOME

# 2. Wait briefly for onSaveInstanceState completion, then kill the background process
sleep 2
adb shell am kill com.example.nav3qa

# 3. Relaunch from launcher/Recents to force NavBackStack deserialization
adb shell am start -n com.example.nav3qa/.MainActivity

Immediately after relaunch, Claude Code inspects all three ScreenSync MCP signals:

  • get_logcat: Searches for SerializationException, IllegalStateException, or BACKSTACK_CHANGED confirming the restored stack equals [ProductList, ProductDetail("sku-42"), CheckoutReview("sku-42", 3)].
  • get_ui_hierarchy: Verifies the restored top screen still displays "sku-42" and quantity "3" rather than silently resetting to ProductList.
  • get_latest_screenshot: Confirms no blank render frame, overlapping inset, or truncated checkout summary appears during cold restoration.
Failure Mode Symptom in Unit / Robolectric Tests Real-Device Behavior Caught by ScreenSync MCP Root Fix in Navigation 3
Missing SavedStateNavEntryDecorator Passes if tests don't push/pop full entries Scroll offset and form inputs wipe on single-pane push/pop Add rememberSavedStateNavEntryDecorator() to entryDecorators
Unregistered @Serializable NavKey Never triggers without real Bundle parceling Crash with SerializationException after am kill + relaunch Annotate all NavKey subtypes and register SavedStateConfiguration
Missing ViewModelStoreNavEntryDecorator Passes if ViewModel clearing isn't asserted DetailViewModel.onCleared() never fires after removeLastOrNull() Add rememberViewModelStoreNavEntryDecorator() before entryProvider
Non-Idempotent backStack.add() Single synthetic click fires once Rapid physical double-tap pushes duplicate detail screens Deduplicate against backStack.lastOrNull() before mutating list
Scene-Unaware Back Handler Passes in single-pane Activity tests Tapping detail Back button on tablet clears pane awkwardly Gate detail top-bar Back visibility on current Scene pane count

Validating Predictive Back, Custom Transitions, and Cross-Surface Deep Links

Validating Navigation 3 transitions on Android 14, Android 15, and Android 16 requires testing interactive edge-swipe back previews and external deep-link intents that rewrite the SnapshotStateList. ScreenSync MCP records frame streams via record_screen during control_swipe gestures and bridges browser links via its Chrome and Edge extension.

Navigation 3 exposes transitionSpec, popTransitionSpec, and predictivePopTransitionSpec directly on NavDisplay. Unlike static XML animations, a misconfigured BackHandler or custom ContentTransform can freeze an interactive predictive back swipe halfway across the screen or flash stale destination state behind the outgoing card.

Testing Interactive Predictive Back on Real Hardware

Using ScreenSync MCP, Claude Code executes a partial-to-complete edge swipe with control_swipe while capturing the frame stream via record_screen. Following the patterns in testing Android predictive back gestures, Claude Code verifies:

  • Whether NavDisplay reveals the underlying ProductList surface cleanly as ProductDetail scales down during the edge drag.
  • Whether canceling a back swipe mid-gesture keeps ProductDetail active without triggering DetailViewModel.onCleared().
  • Whether completing the swipe invokes onBack = { backStack.removeLastOrNull() } cleanly while preserving at least one root key when desired.

Cross-Surface Web-to-Nav3 Deep Link Verification

Mobile commerce and auth flows frequently begin in a desktop or mobile browser—such as clicking a verification email, OAuth redirect, or checkout return—and land deep inside a nested Navigation 3 stack ([ProductList, ProductDetail("sku-42"), CheckoutReview("sku-42", 1)]).

Because ScreenSync MCP includes *197 `web_` browser tools through its MV3 Chrome and Edge extension alongside its 29 phone and desktop tools**, Claude Code can coordinate cross-surface verification in one session:

  1. Drive a web portal or test fixture in your real desktop Chrome tab (where risky browser actions trigger a human approval prompt).
  2. Dispatch the resulting deep-link URI to the connected Android phone via ADB intent launch, applying the validation steps from testing Android deep links and app links.
  3. Inspect get_ui_hierarchy and get_logcat on the Android device to confirm your NavBackStack synthesized the full parent hierarchy (ProductList followed by ProductDetail and CheckoutReview), ensuring a subsequent control_swipe back steps upward naturally instead of closing the app.

Automating Navigation 3 Regressions in Developer Feedback Loops

Automating Navigation 3 regression checks with Claude Code turns manual pre-merge smoke testing into repeatable natural-language verification scripts backed by ScreenSync MCP telemetry. Developers can isolate broken key transitions, patch Kotlin reducers, redeploy via Gradle, and re-verify on the same physical phone within minutes.

Unlike brittle XPath suites that break whenever a Material 3 container shifts, Claude Code pairs get_ui_hierarchy resource IDs (testTagsAsResourceId = true) with BACKSTACK_CHANGED Logcat events. When a Navigation 3 regression fails during local verification:

  1. Locate the root cause in code: Claude Code reads the failing BACKSTACK_CHANGED sequence from get_logcat, identifies the exact entry<T> lambda or SceneStrategy mismatch in your Kotlin source, and patches the guard or SavedStateConfiguration.
  2. Rebuild and install over ADB: Claude Code runs ./gradlew installDebug from your repository terminal and launches the updated APK onto the paired device.
  3. Re-run the real-device check: Using control_tap, get_ui_hierarchy, get_latest_screenshot, and get_logcat, Claude Code confirms the fix on actual Android hardware before you open a pull request.

Comparing ScreenSync MCP Against Other Android MCP Approaches

Choosing an Android Model Context Protocol server for Navigation 3 testing depends on whether you need zero-root MediaProjection screen capture, real-device UI tree inspection, and unified desktop browser automation in one server. ScreenSync MCP provides all three locally without requiring cloud device rentals.

If you are comparing Android MCP servers for Claude Code, Cursor, or VS Code agent mode, architectural differences directly impact Navigation 3 test reliability:

  • ScreenSync MCP (by EpsolDev): Runs a local Node.js 18+ hub on port 3000 (stdio for MCP clients), pairs with the free Android 7.0+ app (com.screensync.mcp), captures frames via MediaProjection with no root and no ADB (~94 ms median LAN mirror in EpsolDev's tests), dispatches 12 control_* tools over ADB, and bundles 197 web_* Chrome/Edge tools in the same server.
  • ADB-only wrappers (such as scrcpy-mcp or Android-MCP): Focus purely on ADB shell, screencap, or uiautomator dumps without a dedicated MediaProjection streaming app or integrated browser extension.
  • Cross-platform driver wrappers (such as mobile-mcp): Wrap general automation drivers across simulators and emulators, whereas ScreenSync MCP specializes in Android hardware plus local Chrome/Edge browser workflows.

For broader autonomous QA workflows across physical Android phones, see can Claude Code test Android apps on real mobile devices.

Production Checklist for Claude Code + Navigation 3 CI and Local QA

Before merging a Jetpack Navigation 3 migration or adaptive multi-pane flow, engineering teams should run this deterministic verification checklist with Claude Code and ScreenSync MCP against connected Android hardware to catch duplicate pushes, decorator omissions, serialization failures, and predictive back glitches before release:

  • Idempotent Stack Guard: Rapid double-taps via control_tap never push duplicate NavKey entries onto SnapshotStateList.
  • Decorator Completeness: rememberSavedStateNavEntryDecorator() and rememberViewModelStoreNavEntryDecorator() are both attached to NavDisplay.
  • Lifecycle Cleanup: get_logcat confirms DetailViewModel.onCleared() executes immediately after removeLastOrNull() pops an entry.
  • Serialization Resilience: Killing the backgrounded process (adb shell am kill) and relaunching restores the exact NavKey hierarchy without SerializationException.
  • Adaptive Scene Geometry: Toggling display width verifies ListDetailSceneStrategy renders non-overlapping panes in get_ui_hierarchy and crisp spacing in get_latest_screenshot.
  • Predictive Back & Deep Links: control_swipe + record_screen confirm smooth back previews and synthesized parent back stacks on external intent entry.

Ready to let Claude Code inspect and test your Jetpack Navigation 3 flows on real Android hardware? Use the links below to download the free Android app and follow the step-by-step hub installation guide.

Next steps

FAQ

Questions, answered

Why test Jetpack Navigation 3 on real Android hardware instead of Compose unit tests alone?

Compose unit tests with TestNavHostController or local SnapshotStateList checks run on a simulated clock without real OEM window insets, system predictive back gestures, or Android 16 multi-pane configuration changes. Real-device testing catches NavDisplay scene transitions, SavedStateNavEntryDecorator restoration failures, and ViewModelStore clearing bugs under actual hardware memory and display conditions.

Does ScreenSync MCP require root access or ADB to inspect Navigation 3 screens?

Screen capture in ScreenSync MCP uses Android's native MediaProjection API after per-session user consent and requires no root and no ADB. However, interactive control tools such as control_tap, control_swipe, and control_type require ADB over USB or wireless debugging from the desktop hub to dispatch inputs.

How does Claude Code verify NavBackStack state when Navigation 3 has no NavController?

Because Jetpack Navigation 3 replaces the opaque NavController with a developer-owned SnapshotStateList of NavKey objects, Claude Code inspects UI state through ScreenSync MCP's get_ui_hierarchy and get_latest_screenshot tools while correlating structured navigation logs from get_logcat to verify exact stack pushes, pops, and multi-pane scene selections.

How can Claude Code test ListDetailSceneStrategy across phone and tablet layouts?

Claude Code runs ScreenSync MCP's control_tap and control_swipe actions to drive list-item selection on a physical device or foldable, triggers ADB display density or orientation overrides, and inspects get_ui_hierarchy and get_latest_screenshot to confirm whether NavDisplay renders SinglePaneSceneStrategy or side-by-side ListDetailSceneStrategy panes.

How do SavedStateNavEntryDecorator and ViewModelStoreNavEntryDecorator affect Navigation 3 tests?

Entry decorators in Jetpack Navigation 3 control whether each NavEntry retains UI state and ViewModel instances across configuration changes or back stack pops. Testing on a real device exposes missing SavedStateNavEntryDecorator registrations or leaked ViewModels when a NavKey is removed from the SnapshotStateList.

What happens to screenshots captured during automated Navigation 3 QA runs?

ScreenSync MCP streams MediaProjection frames directly from the Android device to the local desktop hub on your network, never to EpsolDev servers, with optional Google Drive fallback. Whenever Claude Code or another AI agent calls get_latest_screenshot, that requested image is transmitted to the agent's model provider for visual analysis.

Can ScreenSync MCP test Navigation 3 deep links that originate in Chrome on desktop or mobile?

Yes. ScreenSync MCP exposes 226 tools total—29 phone and desktop tools plus 197 web_* browser tools. Claude Code can trigger or inspect an OAuth or web checkout link inside Chrome via the extension, then verify the incoming intent, NavKey parsing, and rendered NavDisplay screen on the Android phone.

Which Android versions and MCP clients support ScreenSync MCP for Navigation 3 testing?

The ScreenSync MCP Android app supports Android 7.0 or later and is free on Google Play. The Node.js 18+ desktop hub runs on Windows, macOS, and Linux over stdio for local Model Context Protocol (MCP) clients including Claude Code, Claude Desktop, Cursor, and VS Code agent mode.

Written by

ScreenSync MCP team

The ScreenSync MCP team at EpsolDev builds the Android app, the desktop MCP hub and the browser extension that let AI agents see and control a real phone. These guides come out of that work.