We are currently working on our product and as it is a very big app in architecture, so we divided our app into feature and library modules. One such module is credit_cards
which is a dynamic feature module. Here is the AndroidManifest
of the module.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.tallileo.credit_cards">
<dist:module
dist:instant="false"
dist:title="@string/text_feature_credit_cards">
<dist:delivery>
<dist:install-time />
</dist:delivery>
<dist:fusing dist:include="false" />
</dist:module>
</manifest>
As you can clearly see, the module is configured to be an install-time
module but when I open the module via Navigation Components, it works as an on-demand
feature module.
Here is the code I am using to navigate to the module.
nav_graph_app.xml
<fragment
android:id="@+id/trackFragment"
android:name="com.tallileo.tallileo.ui.TrackFragment"
android:label="@string/text_track"
tools:layout="@layout/fragment_track">
<action
android:id="@+id/action_trackFragment_to_nav_graph_accounts"
app:destination="@id/nav_graph_accounts" />
<action
android:id="@+id/action_trackFragment_to_nav_graph_categories"
app:destination="@id/nav_graph_categories" />
<action
android:id="@+id/action_trackFragment_to_nav_graph_transactions"
app:destination="@id/nav_graph_transactions" />
<action
android:id="@+id/action_trackFragment_to_nav_graph_budget"
app:destination="@id/nav_graph_budget" />
<action
android:id="@+id/action_trackFragment_to_nav_graph_credit_cards"
app:destination="@id/nav_graph_credit_cards" />
</fragment>
Utility.kt
fun getFeatureNavAction(featureName: FeatureName): NavDirections =
when (featureName) {
FeatureName.BUCKET_LIST -> SaveFragmentDirections.actionSaveFragmentToNavGraphBucketList()
FeatureName.BUDGET -> TrackFragmentDirections.actionTrackFragmentToNavGraphBudget()
FeatureName.CATEGORIES -> TrackFragmentDirections.actionTrackFragmentToNavGraphCategories()
FeatureName.CREDIT_CARDS -> TrackFragmentDirections.actionTrackFragmentToNavGraphCreditCards()
...
}
We have ~7-8 other feature modules and they also have the same config in their respective AndroidManifest
files. And as seen in the above function, I am using the same navigation methods for them too. Now the weird part is only the credit_cards
module work as on-demand
even after giving it all the config of install-time
. Whereas all the other feature modules work just fine.