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

Flutter Android应用无法通过App Links启动问题求助

问题:App Links无法启动Flutter Android应用,仅跳转网页

尝试通过App Links实现从URL启动Flutter开发的Android应用,但应用并未打开,仅跳转至网页。无论是直接在搜索栏输入URL,还是通过<a>标签按钮跳转,结果均一致。


AndroidManifest.xml(已将<example.com>替换为自定义域名)

<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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="http" />
    <data android:host="<example.com>" />
</intent-filter>

<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<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="<example.com>" />
</intent-filter>

获取SHA256

执行命令:

./gradlew signingReport

结果:

Variant: debug
Config: debug
Store: 
Alias: AndroidDebugKey
MD5: 
SHA1: 
SHA-256: <debug key>
Valid until: 
----------
Variant: release
Config: release
Store: 
Alias: key
MD5: 
SHA1: 
SHA-256: <release key>
Valid until: 
----------

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.app1",
      "sha256_cert_fingerprints":
        ["<debug key>", "<release key>"]
    }
  }
]

环境代码

MainActivity.kt

package com.example.app1

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity()

排查与解决步骤
  1. 验证assetlinks.json的有效性

    • 确保https://<example.com>/.well-known/assetlinks.json可直接通过浏览器访问,返回的JSON无语法错误
    • 检查返回的Content-Type是否为application/json,部分服务器默认返回text/plain会导致验证失败
  2. 核对SHA256指纹格式

    • 确保指纹无多余空格、换行,字母为大写(Android验证对大小写敏感)
    • 严格对比signingReport输出的SHA-256与assetlinks.json中的值,包括冒号分隔的格式
  3. 优化intent-filter配置

    • 移除重复的<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />,仅在<activity>标签内保留一份
    • 将http和https的scheme合并到同一个intent-filter,减少冗余:
      <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
      <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="http" android:host="<example.com>" />
          <data android:scheme="https" android:host="<example.com>" />
      </intent-filter>
      
  4. 检查App Links验证状态

    • 在设备上进入设置 -> 应用 -> 你的应用 -> 打开方式,查看是否显示「已验证」
    • 若显示「未验证」,运行adb shell am start -a android.intent.action.VIEW -d "https://<example.com>"触发验证,再用adb logcat -s IntentFilterVerification查看失败日志
  5. 测试环境匹配

    • 确保安装的APK签名与assetlinks.json中的指纹对应:debug版本用debug签名,release版本用release签名
    • 部分浏览器需清除缓存或手动开启「打开应用」权限

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 12:40:18