Home » Android » android – Navigation component with instant/(dynamic-)feature modules

android – Navigation component with instant/(dynamic-)feature modules

Posted by: admin May 14, 2020 Leave a comment


I’m trying to implement the new navigation component with dynamic features

So the structure looks like this:

  • app (has dynamic dynamicFeatures = [] included in gradle)
  • features

    • login
    • home
    • etc.
  • library -> globalNav

I’ve been reading a lot with no success how to glue these together without depending on each other as each feature is completely isolated

e.g The app (app module) starts with the SplashActivity and checks the session state, so my question is how should I start the login_graph or home_graph and in the first case, start the home after finishing the auth flow?

The way I’m currently trying gluing’em together is using a globalNav module (android-library) I found a couple of workarounds:

  • Complete classpath, meaning I start the intent with the className (bad as this is not really scalable and makes maintaining a PITA)
Intent().setClassName(context.packageName, className).also { context.startActivity(it) }
  • Deeplinks (the one I wanted to use as my nav graph already has those) but for some reason, it always shows the “Choose complete action” picker even though only my app takes it.

    • I’ve already tried using actions but the same behavior as deeplinks

Any suggestions would be great 🙂

PS: Some references that I’ve been viewing/reading on:

PSS: I’m actively trying to figure this out if I find a good solution I’ll make sure to answer too.


For anyone interested in this, as it isn’t currently supported, you can star the issue here: https://issuetracker.google.com/issues/132170186

How to&Answers:

We’re actively working to support navigation for dynamic feature modules. As Joaquim said, this isse was the place to look for progress of initial development.

You can use the SNAPSHOT by adding this to your build.gradle files today:

repositories {
  maven {
    url "https://ci.android.com/builds/submitted/5956592/androidx_snapshot/latest/repository/"
dependencies {
  implementation "androidx.navigation:navigation-dynamic-features-fragment:2.3.0-SNAPSHOT"

This is not a stable version and there are likely to be changes before a stable release. There is also no public documentation on the library at this point. I will update this question as we move along.

In the meantime you can also watch the recording on this from the Android Dev Summit 2019.


I was also facing with same problem couple minutes ago and I saw your question while trying to find an answer.

In my case I am having 2 modules app and login. The module login is dynamic-feature module which depends on module app. The module login contains all the logic and navigation for logging purpose (it contains login, register and so on). I wanted to include this LoginActivity (which is an activity in login module which has all navigation in it) in the main navigation graph in app module. We can not call LoginActivity from app layer which it does not know about it. But

<activity android:id="@+id/loginActivity"

adding it manually in main nav graph worked for me.