Sanniv Khare 7 min read

Navigation 3 dynamic features: on-demand modules, no fragments

Navigation 3 dynamic features: on-demand modules, no fragments

Navigation 3 finally has an answer to Navigation 2’s DynamicNavHostFragment. Version 1.3.0-alpha05, released on 18 November 2026, adds a navigation3-dynamic-features artifact: you register an on-demand feature module against a key, a NavEntryDecorator starts the Play Feature Delivery install the first time someone navigates to that key, and the module’s screens appear in place once it lands. Before you try it, budget for the toolchain: the alpha pulls in Compose 1.14.0-alpha01, which needs compileSdk 37.2, Android Gradle Plugin 9.4.0 and therefore Gradle 9.6.0.

We read the artifact’s published sources and AAR, compared them with the release notes and the Navigation 2 feature module guide, and built a base app plus one on-demand module with it on our M1 lab Mac (JDK 17).

Why we did this: the banking apps we build for clients have flows most users never open (a loan or KYC journey), which are natural on-demand modules, and Navigation 3 is where new Compose navigation code is heading. Until this release, combining the two meant keeping a fragment host around just for the dynamic parts.

What is in the artifact

The release notes describe the feature in three bullets. The sources jar has four files, and they answer most of the questions the notes leave open.

  • rememberDynamicFeatureNavEntryDecorator(): creates the decorator. defaultLoadingContent is required; splitInstallManager defaults to rememberSplitInstallManager().
  • DynamicFeatureNavEntryDecorator.entryProvider { }: builds the entry provider for NavDisplay, with an optional fallback for unknown keys.
  • dynamicFeatureModule(...): registers a module against its first key, with initialKey, moduleName, entryProviderClassName and an optional per-module loadingContent.
  • DynamicFeatureModuleEntryProvider<K>: an interface you implement inside the feature module, with one function, EntryProviderScope<K>.buildEntries().
  • rememberSplitInstallManager(): SplitInstallManagerFactory.create(applicationContext), remembered per context.

The change that makes this possible sits in navigation3-runtime. Diffing the 1.2.2 and 1.3.0-alpha05 sources jars, EntryProviderScope went from public class to public open class, and build() went from @PublishedApi internal to public. That matches the API change listed in the release notes, and it is what lets DynamicFeatureEntryProviderScope extend the normal DSL, so entry<HomeKey> { } and dynamicFeatureModule(...) live in the same block.

Navigation 2 and Navigation 3 dynamic feature APIs side by side

Navigation 2 does the same job with a fragment host, XML attributes and an install monitor.

How a navigation to an uninstalled module plays out

Reading DynamicFeatureEntryProvider and DynamicFeatureNavEntryDecorator gives this sequence:

  1. You push PremiumKey. The entry provider sees that the key belongs to a registered module whose name is not in splitInstallManager.installedModules, and returns a placeholder NavEntry whose content is your loading composable.
  2. The decorator spots that placeholder through a metadata key and starts SplitInstallRequest.newBuilder().addModule("premium"). A session id of 0 from startInstall means the module is already there, and the code emits a synthetic INSTALLED state.
  3. Your loading composable receives every SplitInstallSessionState: bytes downloaded, FAILED with an error code, REQUIRES_USER_CONFIRMATION. Handling confirmation is your job: the docs point to startConfirmationDialogForResult, and nothing in the library calls it for you.
  4. On INSTALLED, the decorator calls SplitCompat.install(context) and SplitInstallHelper.updateAppInfo(context), then creates your provider class with Class.forName(name).getConstructor().newInstance() and runs its buildEntries(). A state flag on the module triggers recomposition, so the placeholder is replaced by the real screen while the back stack stays as it was.
  5. If the user backs out while the download is still running, a DisposableEffect calls cancelInstall on the session.

Two details are worth knowing before you design keys. Sub-screen keys that only the feature module knows about (an internal key such as PremiumDetailKey) still resolve after process death: when the provider sees a key it does not recognise, it initialises every installed module first and then looks again. And because the provider is created by reflection, a typo in entryProviderClassName shows up at runtime as IllegalStateException: Cannot instantiate the DynamicFeatureModuleEntryProvider with class name ..., not at compile time.

R8: the keep rule ships with the library

Reflection plus R8 usually means a manual keep rule. Here the AAR carries one:

The AAR metadata and the keep rule bundled in navigation3-dynamic-features

Unpacked from navigation3-dynamic-features 1.3.0-alpha05.

The rule keeps every class that implements DynamicFeatureModuleEntryProvider, together with its public no-argument constructor, as long as the library’s own provider class survives. So your provider class must have a public no-arg constructor (a plain class, not an object, because getConstructor() only finds public constructors), and you should not add a rule that obfuscates it away.

The build requirements

Our first build of the sample, on the AGP 9.2.1 setup we use for other Compose tests, stopped at the AAR metadata check with six issues, two per library:

Dependency 'androidx.navigation3:navigation3-ui-android:1.3.0-alpha05'
requires libraries and applications that depend on it to compile against
version 37.2 or later of the Android APIs.
Dependency 'androidx.navigation3:navigation3-ui-android:1.3.0-alpha05'
requires Android Gradle plugin 9.4.0 or higher.

The same two messages came from androidx.compose.ui:ui-android and androidx.compose.animation:animation-android at 1.14.0-alpha01, which navigation3-ui 1.3.0-alpha05 pulls in. The dynamic-features artifact itself only asks for compileSdk 37 and AGP 9.1.0. Moving to AGP 9.4.0 then failed with “Minimum supported Gradle version is 9.6.0”. With AGP 9.4.0, Gradle 9.6.0 and the new minor-level compileSdk syntax, both modules compiled:

android {
    compileSdk { version = release(37) { minorApiLevel = 2 } }
    dynamicFeatures += setOf(":premium")
}

The first full compile of the base and feature modules took 1 min 30 s on our lab Mac, including dependency resolution, and the debug bundle another 24 s. These are single runs on one machine, useful only to show the setup works.

A release bundle with R8 enabled also built (2 min 41 s for that step). The R8 configuration printed during the build contains the library’s keep rule, and the mapping file shows the provider class kept under its original name:

com.ideaxecution.navlab.premium.PremiumEntries -> com.ideaxecution.navlab.premium.PremiumEntries:

So the string in entryProviderClassName still points at a real class after shrinking, with no rule of our own.

If your app is on stable Compose, this is the real cost of trying the alpha: an AGP and Gradle jump for the whole project, and Compose alphas everywhere. For a production banking app we will wait for a beta that sits on stable Compose; for a spike branch it is fine.

The feature module side

Inside the on-demand module, one class lists its screens. This is the version that compiled in our sample:

package com.ideaxecution.navlab.premium

internal data object PremiumDetailKey : NavKey

class PremiumEntries : DynamicFeatureModuleEntryProvider<NavKey> {
    override fun EntryProviderScope<NavKey>.buildEntries() {
        entry<PremiumKey> { BasicText("Premium home") }
        entry<PremiumDetailKey> { BasicText("Premium detail") }
    }
}

PremiumKey lives in the base module, because the base has to name it when it registers the module. Keys for screens deeper inside the feature can stay internal to it.

The base module registers it next to its normal entries:

val dynamic = rememberDynamicFeatureNavEntryDecorator<NavKey>(
    defaultLoadingContent = { BasicText("Loading...") }
)
NavDisplay(
    backStack = backStack,
    onBack = { backStack.removeLastOrNull() },
    entryDecorators = listOf(
        rememberSaveableStateHolderNavEntryDecorator(),
        dynamic,
    ),
    entryProvider = dynamic.entryProvider {
        entry<HomeKey> { HomeScreen(onPremium = { backStack.add(PremiumKey) }) }
        dynamicFeatureModule(
            initialKey = PremiumKey,
            moduleName = "premium",
            entryProviderClassName = "com.ideaxecution.navlab.premium.PremiumEntries",
            loadingContent = { state -> PremiumLoading(state) },
        )
    },
)

The feature module itself is a standard com.android.dynamic-feature module with <dist:on-demand /> delivery and a dependency on the base, exactly as for Navigation 2.

  • DynamicNavHostFragment becomes a DynamicFeatureNavEntryDecorator passed to NavDisplay.
  • app:moduleName on a destination becomes moduleName in dynamicFeatureModule().
  • <include-dynamic> with app:graphResName becomes the entryProviderClassName of a DynamicFeatureModuleEntryProvider.
  • DynamicInstallMonitor and DynamicExtras become a loadingContent composable that receives SplitInstallSessionState.
  • AbstractProgressFragment and DefaultProgressFragment become the defaultLoadingContent composable.
  • In Navigation 2 only the start destination of an included graph is reachable; in Navigation 3 only initialKey triggers the install, and sub-keys resolve after it.

The Navigation 3 overview page does not mention dynamic features yet, so the release notes and the sources are the documentation for now.

What to check before adopting it

  • Your whole project can move to AGP 9.4.0, Gradle 9.6.0 and compileSdk 37.2, and you accept Compose 1.14 alphas.
  • Every provider class is a class with a public no-arg constructor, and its fully qualified name is written correctly; consider a unit test that loads it with Class.forName.
  • Your loading composable handles FAILED and REQUIRES_USER_CONFIRMATION, since large modules on mobile data can ask for confirmation.
  • Download, cancel and confirmation behaviour need a Play-delivered build (internal app sharing or bundletool with local testing) on a real device; a build deployed from the IDE usually installs every module up front and never exercises the install path.

If you are still on Navigation 2, our Navigation 2 to Navigation 3 1.2 porting guide covers the rest of the move.

Made by the team behind this post

Apps from our studio

  • Goes with this post

    BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.