[英]Is there a way to create implicit deeplink in Android Multi-module project using Navigation Component
我有一個多模塊項目,我需要在應用程序中處理深層鏈接。 深度鏈接可以是任何具有自己的導航圖的功能模塊。 這是一個單一活動項目。
我的項目包括功能1,功能2和主應用程序模塊的模塊,這取決於兩個功能模塊。 每個模塊都包含自己的導航圖以維護自己的流程。 我正在嘗試創建一個隱式深層鏈接,如文檔中所示
我的app模塊的導航圖有嵌套的功能1和2s圖,如下所示
<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/navigation_main"
app:startDestination="@id/start_destination"
tools:ignore="UnusedNavigation">
<include app:graph="@navigation/navigation_feature_one" />
<include app:graph="@navigation/navigation_feature_two" />
我有導航圖中定義的功能一的深層鏈接 - navigation_feature_one
<navigation>
...
<fragment android:id="@+id/featureOneFragment"
android:name="com.app.featureone.presentation.SomeFragment"
tools:layout="@layout/some_fragment"
android:label="@string/title_some_fragment">
<deepLink app:uri="www.example.com/featureone"/>
</fragment>
</navigation>
在AndroidManifest中,我已經指出應該使用具有嵌套圖形的主導航
<activity
android:name=".presentation.NavigationActivity"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="www.example.com"/>
<data android:scheme="https"/>
<data android:scheme="http"/>
</intent-filter>
<nav-graph android:value="@navigation/navigation_main" />
</activity>
我期望項目使用導航組件深入鏈接到應用程序中的任何模塊,但是在編譯期間我發現錯誤,無法找到包含的圖形
Referenced navigation file with navigationXmlId = navigation_feature_one not found
此問題看起來可能是此錯誤的表現https://issuetracker.google.com/issues/112513722
問題跟蹤器建議將此作為解決方法:
// Copy these to the app module's build.gradle
task copyChildNavigationGraphs(type: Copy) {
from '../feature-module/src/main/res/navigation'
into 'src/main/res/navigation'
}
preBuild.dependsOn copyChildNavigationGraphs
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.