数字资产 Link link 到我的网站

Digital Assets Link link to my website

我创建了一个免安装应用程序。我将其上传到我的 Google 控制台,但出现此错误。

The www.kochchy.cz website has not been linked to your application through the Digital Assets Link protocol. Link the application site with Digital Assets Link.

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
   "namespace": "android_app",
    "package_name": "com.kochchy.instantapptest.app",
    "sha256_cert_fingerprints":["A4:A6:74:15:F1:3E:38:3F:93:0F:EF:E3:A6:86:8E:7C:25:45:E8:80:5B:5E:35:70:49:20:DB:F8:CB:D4:FC:E0"]
  }
}] 

即时和可安装的 apk 使用相同的 ID:com.kochchy.instantapptest.app(每个都在自己的模块清单中定义)

我的 base 模块清单如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kochchy.instantapptest">

<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:theme="@style/AppTheme">

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <meta-data
            android:name="default-url"
            android:value="https://www.kochchy.cz" />

        <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:scheme="http" />
            <data android:host="www.kochchy.cz" />
            <data android:pathPattern="/menu" />
        </intent-filter>
    </activity>
</application>
</manifest>

------ 编辑 ------

我从 google 即时应用程序示例创建了新项目:https://github.com/googlesamples/android-instant-apps/tree/master/hello

相同的 google 控制台错误。我想我的网络设置有问题,而不是在应用程序中。

The www.kochchy.cz website has not been linked to your application through the Digital Assets Link protocol. Link the application site with Digital Assets Link.

在您的 json 文件中,字段 package_name 设置为 com.kochchy.instantapptest.app

但是,您的 AndroidManifest.xml 中的包名称设置为 com.kochchy.instantapptest.

它们应该匹配。

编辑

您的结构看起来与 Google 推荐的完全不同。

您不必复制您的代码和资源。相反,创建第三个模块(我们称它为基础)作为基础功能模块,并将所有代码和资源移到那里。确保它的 build.gradle 包括这些行:

apply plugin: 'com.android.feature'

android {
    baseFeature true
    ...
}

dependencies {
    application project(':app')
    ...
}

在您应用的 build.gradle 中,确保您有这些行:

apply plugin: 'com.android.application'
...
dependencies {
    implementation project(':base')
}

最后,在您的即时应用的 build.gradle:

apply plugin: 'com.android.instantapp'
...
dependencies {
    implementation project(':base')
}

您可能需要进行进一步的更改,但这应该是一个好的开始。我强烈建议您看一下 this page,特别是 "Structure of a basic instant app".

部分
"package_name": "com.kochchy.instantapptest.app"

这里你的应用程序 ID 应该来自可安装的应用程序,而不是来自即时应用程序清单

defaultConfig {
    applicationId "com.example.yourappid"
}

尝试按照以下步骤操作并验证生成的文件是否与您的相同:

工具 -> 应用程序 Links 助手 ->(单击按钮)打开数字资产 Links 文件生成器

完成所有内容后,单击生成数字资产Links 文件

单击“保存文件”进行下载。

将 assetlinks.json 文件上传到您的站点,每个人都可以阅读,位于 https://www.exemple.com/.well-known/assetlinks.json

单击 Link 和验证 以确认您已将正确的数字资产 Links 文件上传到正确的位置。

参考:https://developer.android.com/studio/write/app-link-indexing.html#associatesite

sha256_cert_fingerprints 有问题。应用程序应用程序歌唱已启用,所以我从 google 播放控制台复制了 sha 并将其放入 asserlink.json 文件并且它有效。

https://d5rwdr23d4fqx.cloudfront.net/.well-known/assetlinks.json

检查 assetlinks.json。具有文件权限 可执行 public

默认情况下,它可能只能读到 public 。 然后确保如果启用 google 播放应用程序签名使用播放控制台中提供的 ssh 密钥。

在我的例子中,是这样的:

如果您已经正确地完成了所有其他操作并且正在紧张,请考虑确保您添加到 Web 服务器的文件具有正确的编码(在我的情况下没有 BOM)。谢谢,Visual Studio! :/

所以对我来说,也许这对某些人来说是显而易见的,是使用了错误的 sha 密钥。 您需要做的是转到 https://play.google.com/apps/publish/ 控制台

转到发布管理,然后转到应用签名页面。从那里复制 SHA256 密钥。

转到 https://developers.google.com/digital-asset-links/tools/generator 并在其中输入 sha 密钥、url 和程序包名称。

将此文件上传到 https://example.com/.well-known/assetlinks.json

确保文件位于正确的位置:名为 .well-known.

的文件夹

发布您的免安装应用