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

配置Android App Link含sspPattern后仍跳转Chrome问题求助

问题分析与解决办法

你的核心问题是App Links验证未生效,导致系统没有将你的App设为含deeplink参数URL的默认处理者,Chrome因注册了更宽泛的匹配规则(比如所有https://www.example.com/*),被系统优先调用。以下是具体排查方向和解决方案:

  • 格式与内容正确性:确保assetlinks.json是标准JSON数组,包含正确的包名、SHA-256签名指纹,示例格式如下:
    [
      {
        "relation": ["delegate_permission/common.handle_all_urls"],
        "target": {
          "namespace": "android_app",
          "package_name": "com.your.package",
          "sha256_cert_fingerprints": ["你的SHA-256指纹"]
        }
      }
    ]
    
    注意指纹要和打包用的签名一致(debug和release签名不同,测试时用debug指纹),且不能有多余的空格或符号。
  • 验证服务器配置:确保https://www.example.com/.well-known/assetlinks.json可通过HTTPS直接访问,无证书错误、无重定向(比如不能跳转到www.example.com/assetlinks.json)。
  • 查看系统验证结果:用adb命令检查你的App是否通过验证:
    adb shell dumpsys package domain-preferred-apps
    
    找到你的包名对应的条目,若verified为false,说明验证未通过,需重新检查assetlinks和服务器配置。

2. 优化intent-filter的sspPattern匹配规则

你当前的sspPattern存在冗余,且可能覆盖不全,建议合并为更简洁的正则,确保所有含deeplink参数的URL都能匹配:

<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />

  <data android:scheme="https" />
  <data android:host="www.example.com" />
  <data android:sspPattern="/?.*deeplink=.*" />
</intent-filter>

这里用/?.*deeplink=.*可以覆盖:

  • 根路径无斜杠:https://www.example.com?deeplink=xxx
  • 根路径有斜杠:https://www.example.com/?deeplink=xxx
  • 子路径后带参数:https://www.example.com/product?deeplink=xxx

3. 处理Chrome的默认应用设置

如果之前用户手动将Chrome设为该域名的默认应用,即使验证通过,系统仍会优先跳转Chrome:

  • 进入系统设置→应用→Chrome→默认应用→清除默认值
  • 之后点击目标URL,系统会弹出选择器,选择你的App并设为默认。

4. 适配Android版本特性

  • 若你的App targetSdkVersion≥31(Android 12+),需在manifest中添加<queries>标签,允许查询浏览器应用,否则可能影响App Links的验证流程:
    <queries>
      <intent>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" />
      </intent>
    </queries>
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 16:55:25