验证 assetlinks.json 给出 ERROR_CODE_MALFORMED_CONTENT

Verifying assetlinks.json gives ERROR_CODE_MALFORMED_CONTENT

我正在尝试在我的网络服务器上设置一个 assetlinks.json 文件,以指示深层链接应由移动应用程序处理,并且登录凭据应在网站和移动设备之间共享 Android 8.

我在我的开发服务器 (https://devtesting.narrpr.com/.well-known/assetlinks.json) 上托管了 assetlinks.json 文件。

[{
        "relation": ["delegate_permission/common.get_login_creds"],
        "target": {
            "namespace": "web",
            "site": "https://devtesting.narrpr.com/"
        }
    },
    {
        "relation": ["delegate_permission/common.get_login_creds", "delegate_permission/common.handle_all_urls"],
            "target": {
                "namespace": "android_app",
                "package_name": "com.rpr.mobile",
                "sha256_cert_fingerprints": [
                    "D3:7B:D8:D7:47:AF:08:2E:BA:EF:02:96:8C:F2:3A:1A:46:F9:B0:81:E9:E3:6D:BA:01:3C:00:59:95:39:8D:21"
                ]
            }
    }
]

当我执行this url测试时,报错:

{
  "maxAge": "599.999999890s",
  "debugString": "********************* ERRORS *********************\n* Error: invalid_argument: Could not parse statement list (not valid JSON): \357\273\277[{\r\n\t\t\\"relation\\": [\\"delegate_permission/common.get_login_creds\\"],\r\n\t\t\\"target\\": {\r\n\t\t\t\\"namespace\\": \\"web\\",\r\n\t\t\t\\"site\\": \\"https://devtesting.narrpr.com/\\"\r\n\t\t}\r\n\t},\r\n\t{\r\n\t\t\\"relation\\": [\\"delegate_permission/common.get_login_creds\\", \\"delegate_permission/common.handle_all_urls\\"],\r\n\t\t\t\\"target\\": {\r\n\t\t\t\t\\"namespace\\": \\"droid\\",\r\n\t\t\t\t\\"package_name\\": \\"com.rpr.mobile\\",\r\n\t\t\t\t\\"sha256_cert_fingerprints\\": [\r\n\t\t\t\t\t\\"D3:7B:D8:D7:47:AF:08:2E:BA:EF:02:96:8C:F2:3A:1A:46:F9:B0:81:E9:E3:6D:BA:01:3C:00:59:95:39:8D:21\\"\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t}\r\n] [0] while fetching Web statements from https://devtesting.narrpr.com./.well-known/assetlinks.json (which is equivalent to 'https://devtesting.narrpr.com/.well-known/assetlinks.json') using download from the web (ID 1).\n********************* INFO MESSAGES *********************\n* Info: No statements were found that match your query\n",
  "errorCode": [
    "ERROR_CODE_MALFORMED_CONTENT"
  ]
}

在调试行中它说它无效 json,但是 jsonlint 不同意。知道我做错了什么吗?

Android 规范要求 android_app 作为命名空间。

- "namespace": "droid",
+ "namespace": "android_app",

通过 Android Studio(而不是手动)生成 assetlinks.json 文件后,它开始工作了。不确定我是否遗漏了内容,或者这是 windows 文本编码的问题。

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.rpr.mobile",
    "sha256_cert_fingerprints":
    ["D3:7B:D8:D7:47:AF:08:2E:BA:EF:02:96:8C:F2:3A:1A:46:F9:B0:81:E9:E3:6D:BA:01:3C:00:59:95:39:8D:21"]
  }
},
{
  "relation": ["delegate_permission/common.get_login_creds"],
  "target": {
    "namespace": "web",
    "site": "https://devtesting.narrpr.com"
  }
},
{
  "relation": ["delegate_permission/common.get_login_creds"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.rpr.mobile",
    "sha256_cert_fingerprints":
    ["D3:7B:D8:D7:47:AF:08:2E:BA:EF:02:96:8C:F2:3A:1A:46:F9:B0:81:E9:E3:6D:BA:01:3C:00:59:95:39:8D:21"]
  }
}]

从剪贴板获取的文件中有错误:

Error: invalid_argument: Could not parse statement list (not valid JSON): 737[...

删除文件开头的错误字符 (737) 或从头开始创建新字符。