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.
So, I was doing a very basic thing wrong. I opened Log and set it to Verbose and there were two particular messages that got me lead to solving this error.
Now, this error was not that helpful but it provided a good starting point to start solving this error. I checked official docs when is this error thrown and found that this error is thrown when the requested module doen not exist on the cloud. Then there were solutions like releasing the app on internal testing on Play Store, or making use of bundletool
but the point is these all solutions are meant for modules which have been configured as on-demand
and not install-time
.
Now this error got me thinking to a pattern between the modules which were not working as expected. Only two modules out of all were not working and both had two words. Whereas modules which were working, had only one word in their name. So I checked and found the error. I have given the name of the module as credit_cards
but was using credit cards
everywhere including nav_graphs
which was the source of error for me.