【发布时间】:2017-03-07 13:35:39
【问题描述】:
我遇到的问题是 AppLinksAutoVerifyWarning 的 lint 测试总是失败并显示错误消息:
应用链接自动验证失败 ../../src/debug/AndroidManifest.xml:17:此主机不支持指向您的应用的应用链接。检查数字资产链接 JSON 文件: https://myhost/.well-known/assetlinks.json
我正在使用特定于目标的 AndroidManifest 进行调试构建,如您在上面看到的。对于那些调试版本,我将 .debug 后缀附加到我的包名称中。因此调试版本将具有包 ID mypackage.debug,而发布版本将只有 mypackage。两个版本都使用相同的发布密钥签名(由于 sharedUserId),并且我确保assetlinks.json 中的指纹与签名的指纹匹配。对于 myhost,有一个有效的 ssl 证书。
我上传了 assetlinks.json 文件,支持 mypackage.debug 和 mypackage 并确保它具有正确的 应用程序/json mimetype。
- 在电话上,应用链接工作正常
- 使用
digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://myhost&relation=delegate_permission/common.handle_all_urls验证不会提供任何错误 - 使用
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://myhost"测试 AppLink 工作正常 - 我使用
developers.google.com/digital-asset-links/tools/generator重新创建、上传和测试了 assetlinks.json,它验证正常并且不会生成具有不同内容的 json 文件 - 使用 textmate 验证 json 语法
- 我还尝试将 intent-filter 从调试 AndroidManifest 移动到主清单,将其移动到没有其他 intent- 的其他活动过滤器
所以一切似乎都很好,只是 lint 不起作用。我可以禁用 lint 检查,但我更愿意启用它,这样我就知道何时出现真正的问题。
我观察到的一件事:如果我将应用链接的 intent-filter 从 https 更改为 http,则来自 lint 的错误消息会更改to:... has incorrect JSON syntax 这更奇怪,因为 android 本身和谷歌验证服务似乎可以很好地验证它。 (可能与我们将所有流量从 http 转发到 https 有关)
当前的意图过滤器是:
<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="myhost"
android:pathPrefix="/open_app"
android:scheme="https"/>
</intent-filter>
【问题讨论】: