Android 应用链接在已发布的版本中无法正常工作,但在本地安装中可以正常工作

Wil*_*ood 6 android applinks android-app-links

我有一个使用应用链接的游戏。从我的计算机运行调试和发布版本时,应用程序链接工作正常,但不适用于从 Google Play 下载的版本。使用 Google Play 版本时,我会收到一个对话框,询问哪个应用程序应该打开链接。

我使用“Google Play 应用签名”并了解发布的 APK 由 Google 签名并具有不同的签名。我已将 Google Play 上列出的应用签名证书中的 SHA-256 证书指纹添加到我的assetlinks.json 中,因此它包含来自本地和 Google Play 版本的指纹。

我还从 Google Play 下载了一个派生的 APK,并确保指纹与 assetlinks.json 文件中的指纹匹配。

这是一个示例 URL,在 Android 中单击该 URL 时应打开该应用程序,它适用于本地构建,但不适用于 Google Play 版本。相反,我收到一个对话框,询问哪个应用程序应该打开链接。

https://letsdraw.fun/ec?parent=Z0ibN7m-H8jO1jCiMRQtY23VTpKjnIch

我正在从实时发布版本的 logcat 中写出 SHA256 指纹,以仔细检查它是否正确,并且看起来一切正常。

原始签名的 APK 和 Google Play 签名的 APK 可以从这里下载。这两个 APK 都是从 Google Play 下载的,一个是“原始的”,一个是“衍生的”,因此除了签名之外,它们应该是相同的。有趣的是,它们的尺寸略有不同。11,590,297 字节 vs 11,601,619 字节。

查看adb shell dumpsys package domain-preferred-apps原始签名 apk的输出是

  Package: com.scribble.exquisitecorpse
  Domains: letsdraw.fun scribble-cloud.appspot.com scribble-cloud-v24-test-dot-scribble-cloud.appspot.com
  Status:  always : 200000000
Run Code Online (Sandbox Code Playgroud)

而 Google Play 签名的 apk 是

  Package: com.scribble.exquisitecorpse
  Domains: letsdraw.fun scribble-cloud.appspot.com scribble-cloud-v24-test-dot-scribble-cloud.appspot.com
  Status:  ask
Run Code Online (Sandbox Code Playgroud)

使用@ymindstorm 提到的测试页面进行测试时

https://developers.google.com/digital-asset-links/tools/generator

我收到消息

成功!主机letsdraw.fun 授予应用程序深层链接到 com.scribble.exquisitecorpse。

您对可能导致这种情况的原因有什么建议吗?

更新: 我现在已将此作为错误报告给 Google,因为我无法弄清楚发生了什么。 https://issuetracker.google.com/issues/162564916

Wil*_*ood 2

我最终得到了谷歌的帮助......这不是一个错误。

构建过程是从文件合并到主机中的network_security_config.xml,因此即使AndroidManifest.xml文件指定:

        <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="letsdraw.fun" android:pathPrefix="/ec" android:scheme="https" />
            <data android:host="letsdraw.fun" android:pathPrefix="/restore" android:scheme="https" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

构建过程中的文件也指定了其他主机:

        <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="http"
                android:host="scribble-cloud-v24-test-dot-scribble-cloud.appspot.com"
                android:pathPrefix="/ec" />

            <data
                android:scheme="https"
                android:host="scribble-cloud.appspot.com"
                android:pathPrefix="/ec" />

            <data
                android:scheme="https"
                android:host="letsdraw.fun"
                android:pathPrefix="/ec" />

            <data
                android:scheme="https"
                android:host="letsdraw.fun"
                android:pathPrefix="/restore" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

这个页面上它指出

仅当系统为清单中的所有主机找到匹配的数字资产链接文件时,它才会将您的应用程序建立为指定 URL 模式的默认处理程序。

问题是我的测试主机没有返回assetlinks.json与其他主机相同的文件。

构建 APK 后,使用 IntelliJ 或 Android Studio 转到Build | Analyze Apk并打开刚刚构建的 APK,检查您的主机是否正确以及assetlinks.json文件是否返回正确的签名。

为什么要这样合并清单文件?希望我们能在这里找到答案!