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: ----------
部署在/.well-known下的assetlinks.json(已替换<My SHA256>)
[ { "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()
排查与解决步骤
验证assetlinks.json的有效性
- 确保
https://<example.com>/.well-known/assetlinks.json可直接通过浏览器访问,返回的JSON无语法错误 - 检查返回的Content-Type是否为
application/json,部分服务器默认返回text/plain会导致验证失败
- 确保
核对SHA256指纹格式
- 确保指纹无多余空格、换行,字母为大写(Android验证对大小写敏感)
- 严格对比
signingReport输出的SHA-256与assetlinks.json中的值,包括冒号分隔的格式
优化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>
- 移除重复的
检查App Links验证状态
- 在设备上进入
设置 -> 应用 -> 你的应用 -> 打开方式,查看是否显示「已验证」 - 若显示「未验证」,运行
adb shell am start -a android.intent.action.VIEW -d "https://<example.com>"触发验证,再用adb logcat -s IntentFilterVerification查看失败日志
- 在设备上进入
测试环境匹配
- 确保安装的APK签名与
assetlinks.json中的指纹对应:debug版本用debug签名,release版本用release签名 - 部分浏览器需清除缓存或手动开启「打开应用」权限
- 确保安装的APK签名与
内容的提问来源于stack exchange,提问作者yolo
相关产品推荐
相关产品推荐

