Android Instant App - Play Console release/deploy 错误和 DAL(数字资产 Link)未关联

Android Instant App - Play Console release/deploy error and DAL(digital Asset Link) not linked

我想弄清楚为什么 Play 商店不接受我的即时应用构建。我已经成功地向测试人员部署了 Alpha 常规应用程序版本,因为它是发布即时应用程序的先决条件。我正在尝试部署 development 发布即时应用程序。我究竟做错了什么?我尝试添加尽可能多的细节。

我是否需要在以下 link 处使用数字资产 Link API 服务来制作即时应用程序或其他内容? https://console.developers.google.com/apis/api/digitalassetlinks.googleapis.com/overview

将即时应用构建上传到播放控制台时出现以下错误:

Your site 'example.com' has not been linked through the Digital Assets Link protocol to your app. Please link your site through the Digital Assets Link protocol to your app.

我有点困惑的一件事是为什么当我单击 link 并验证 时收到错误消息“Adding asset statements failed.”如下图所示: 我注意到,当我单击 link 并验证 按钮时,它会修改 base 中的 strings.xml 文件并添加以下字符串:<string name="asset_statements" translatable="false">[{\n \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n \"target\": {\n \"namespace\": \"web\",\n \"site\": \"https://example.com\",\n }\n}]</string>

我在 basechecklistadvisor 的清单中有以下内容申请标签:<meta-data android:name="asset_statements" android:resource="@string/asset_statements"/>

项目描述和结构:

应用描述:这是一个概念验证应用。可安装的应用程序将打开带有两个按钮的主要功能 activity,单击这些按钮会将您带到清单或顾问 activity。有两个即时应用程序,instantapp-checklist 转到清单 activity 和 instantapp(advisor) 转到顾问 activity.

我的 assetlinks.json 是:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "blah.blah1.blah2.myappname.checklist",
    "sha256_cert_fingerprints":
    ["AA:...:53"]
  }
},
{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "blah.blah1.blah2.myappname.advisor",
    "sha256_cert_fingerprints":
    ["AA:...:53"]
  }
}]

在我的 activity 标签内清单清单如下:

        <meta-data
            android:name="default-url"
            android:value="https://example.com/checklist.html"/>

        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        <intent-filter android:order="1"
                       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"
                android:pathPattern="/checklist.html"/>
            <data android:scheme="https"/>
        </intent-filter>

我做过的自我检查:

assetlinks.json文件中,字段package_name设置为blah .blah1.blah2.myappname.checklist.

然而,上面提到的是可安装应用程序的idblah.blah1.blah2.myappname。也就是说package_name中的AndroidManifest.xml设置为blah.blah1.blah2.myappname.

它们应该匹配。 blah.blah1.blah2.myappname 必须添加到服务器上的 assetlinks.json

strings.xml中,将asset_statements改为:

<string name="asset_statements" translatable="false">[{\n  \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n  \"target\": {\n    \"namespace\": \"web\",\n    \"site\": \"https://qaapps.cio.ny.gov/apps/sandbox/james/hesc/checklist.html\",\n  }\n},{\n  \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n  \"target\": {\n    \"namespace\": \"web\",\n    \"site\": \"https://qaapps.cio.ny.gov/apps/sandbox/james/hesc/advisor.html\",\n  }\n}]</string>

以下是帮助我找到解决方案的其他注释:

  • 我使用以下命令行来测试即时应用程序是否正常工作:adb shell am start -a android.intent.action.VIEW -d "https://example.com/checklist/"
  • 在设备上,我转到 设置 > Google > 即时应用程序 并单击切换到 uninstall/turn-off 即时应用程序,然后再次单击它以重新打开它。还转到 Chrome 设置(设置 > 隐私 > 清除浏览数据)以清除时间范围内的所有数据,所有时间。
  • 在 Chrome 中向免安装应用输入 url 时,它只会打开网站,不会打开免安装应用。如果我点击 link 到网站中的即时应用程序,它会打开即时应用程序而不是网站。

很奇怪,我遇到了同样的问题。解决方案很简单;

正如@olearyj234 提到的 Link 和 Verify 按钮将字符串添加到 string.xml 的末尾。

我只是删除了 string.xml 中的新字符串,然后单击了 "Link and Verify" 按钮。