使用adb可唤起App链接,浏览器输入URL无法唤起的问题求助
问题描述
已在域名中添加assetlinks.json并完成验证,App安装后设置中显示链接已验证;使用adb命令 adb shell am start -W -a android.intent.action.VIEW -d "https://my-domain.org/login?code=sdfsdfsdf" 可正常唤起App,但在设备Chrome浏览器中输入该URL时,仅打开网页无法唤起App。相关AndroidManifest代码如下:
<application android:allowBackup="false" android:icon="${appIcon}" android:label="My app"> <activity android:name=".MainActivity" android:exported="true" android:hardwareAccelerated="true" android:launchMode="singleTask" android:theme="@style/LaunchTheme" android:windowSoftInputMode="adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <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:host="my-domain.org" android:scheme="https" /> </intent-filter> </activity> </application>
解决思路
- 检查Chrome链接处理权限:进入设备设置→应用→Chrome,开启「链接处理」权限,确保允许Chrome打开关联应用。
- 二次确认assetlinks.json有效性:
- 手动访问
https://my-domain.org/.well-known/assetlinks.json,确认文件包含当前测试App的包名和对应签名指纹(注意debug和release签名的区别)。 - 检查文件返回的Content-Type是否为
application/json,错误的MIME类型会导致验证失效。
- 手动访问
- 调整Intent Filter匹配规则:在
<data>标签中添加android:pathPattern=".*",明确匹配所有路径和参数,修改后代码如下:<data android:host="my-domain.org" android:scheme="https" android:pathPattern=".*" /> - 清除Chrome缓存:进入Chrome设置→隐私设置→清除浏览数据,勾选「缓存的图片和文件」后清除,或直接清除Chrome应用数据,避免旧的验证缓存干扰。
- 核对签名一致性:确保测试用App的签名指纹与
assetlinks.json中配置的完全一致,debug包和release包的签名不同会导致Chrome验证失败。 - 排查版本兼容性:更新Chrome到最新版本,或在不同Android系统版本的设备上测试,部分旧版本系统或浏览器对应用链接支持存在差异。
内容的提问来源于stack exchange,提问作者Neigaard
相关产品推荐
相关产品推荐

