我们目前正在开发我们的产品,因为它在架构上是一个非常大的应用程序,所以我们将我们的应用分为功能模块和库模块。其中一个模块是credit_cards,它是一个动态特征模块。这是模块的AndroidManifest。
<?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>可以清楚地看到,该模块被配置为一个install-time模块,但当我通过导航组件打开模块时,它作为一个on-demand功能模块工作。
下面是我用来导航到模块的代码。
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()
...
}我们有~7-8其他功能模块,它们在各自的AndroidManifest文件中也有相同的配置。从上面的函数中可以看出,我对它们也使用了相同的导航方法。现在,奇怪的部分只是credit_cards模块作为on-demand工作,即使在给它提供了install-time的所有配置之后。而所有其他的功能模块工作得很好。
发布于 2022-03-26 13:27:39
所以,我做了一件非常基本的错事。我打开了Log并将其设置为详细,有两条特定的消息使我解决了这个错误。
1.错误(-2):模块不可用。
现在,这个错误并没有那么有帮助,但是它为开始解决这个错误提供了一个很好的起点。我检查了官方文档何时抛出此错误,并发现当请求的模块在云中不存在时抛出此错误。还有一些解决方案,比如在Play Store的内部测试中发布应用程序,或者使用bundletool,但重点是所有这些解决方案都是针对那些配置为on-demand而不是install-time的模块。
2.应用程序中不存在请求模块。安装信用卡()
现在,这个错误让我想到了模块之间的模式,这些模块不像预期的那样工作。在所有模块中,只有两个模块不起作用,而且都有两个词。而正在工作的模块,在它们的名字中只有一个单词。所以我检查并发现了错误。我已经将模块的名称命名为credit_cards,但是在任何地方都使用credit cards,包括nav_graphs,这对我来说是错误的来源。
https://stackoverflow.com/questions/70868932
复制相似问题