You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Navigation Component实现Android Deeplink时Intent解析失败问题

问题分析与解决

你的核心问题是Manifest中的Intent Filter与测试的DeepLink URI不匹配,导致系统无法找到对应的Activity处理Intent。

具体错误点

  1. 你测试的DeepLink是 ftnvegascp://login,对应的scheme是ftnvegascp,host是login。
  2. 但Manifest里的<data>标签设置了android:host="account",这意味着只有ftnvegascp://account这类URI才能匹配当前的Intent Filter,ftnvegascp://login完全不匹配,所以系统报错无法解析Intent。

分步解决

1. 临时修复,先让ADB命令能唤起Activity

修改Manifest中Activity的Intent Filter里的<data>配置,让它匹配测试的URI:

<intent-filter>
    <!-- 保留其他原有配置 -->
    <data android:scheme="${deeplink}" />
    <!-- 把host改成login,或者直接移除host标签以支持多个host -->
    <data android:host="login" />
</intent-filter>

同时确认${deeplink}这个构建变量的值确实是ftnvegascp,否则scheme也会不匹配。

2. 正确配置Navigation Component的DeepLink(最终方案)

按照你的计划,要完全切换到Navigation的DeepLink机制,需要做以下调整:

  • 移除Manifest中Intent Filter里的这些内容:
    • android.intent.action.VIEW action
    • android.intent.category.DEFAULT 和 android.intent.category.BROWSABLE category
    • 所有<data>标签(scheme、host相关)
  • 保留Activity中的<nav-graph android:value="@navigation/nav_graph"/>,Navigation会在构建时自动为你生成所有nav_graph中配置的DeepLink对应的Intent Filter。
  • 确保你的构建方式支持Manifest合并(默认Android Studio项目都支持),或者使用App Bundle格式,这样自动生成的Intent Filter才能正确合并到最终的Manifest中。

3. 验证跳转逻辑

当配置完成后,重新运行ADB命令测试:

adb shell am start -W -a android.intent.action.VIEW -d "ftnvegascp://login"

此时系统应该能唤起Activity,并且Navigation会自动导航到BottomFragment2。

内容的提问来源于stack exchange,提问作者Kratos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 16:37:34