我有一个动态功能模块,它有自己的嵌套导航图。我还有一个动态功能模块,它只是一个片段。如果您有一个带有自己导航图的动态功能模块,我知道您需要使用include-dynamic标记。当我构建应用程序并将应用程序部署到 Play 商店进行内部测试时,动态模块会正确下载。但是,如果我在本地构建/运行 - 当我尝试导航到包含导航图的动态功能模块时,应用程序崩溃。我以为在本地运行时所有东西都捆绑了?有什么我想念的吗?
我得到的错误是android.content.res.Resources$NotFoundException: com.xyz.app_name.two:navigation/two_navigation
main_navigation_graph
<!-- this works locally. module does not contain a nav graph -->
<fragment
android:id="@+id/OneFragment"
android:name="com.xyz.app_name.one.OneFragment"
android:label="{nickname}"
app:moduleName="one"
tools:layout="@layout/one_fragment">
<argument
android:name="nickname"
app:argType="string" />
</fragment>
<!-- this doesn't work locally -->
<include-dynamic
android:id="@+id/two_graph"
app:graphPackage="com.xyz.app_name.two"
app:graphResName="two_navigation"
app:moduleName="two" />
特征二图
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@id/two_graph"
app:moduleName="two"
app:startDestination="@id/twoFragment">
<fragment
android:id="@+id/twoFragment"
android:name="com.xyz.app_name.two.TwoFragment"
android:label="{nickname}"
tools:layout="@layout/two_fragment">
<argument
android:name="nickname"
app:argType="string" />
<action
android:id="@+id/action_twoFragment_to_dialogFragment"
app:destination="@id/dialogFragment" />
</fragment>
<dialog
android:id="@+id/dialogFragment"
android:name="com.xyz.app_name.two.ui.DialogFragment"
android:label="bottom_sheet"
tools:layout="@layout/bottom_sheet" />
</navigation>