【问题标题】:AppLinks on Android 12 - opens browser onlyAndroid 12 上的 AppLinks - 仅打开浏览器
【发布时间】:2022-01-13 11:51:20
【问题描述】:

我有以下清单代码:

<activity
        android:name=".InterceptorActivity"
        android:launchMode="singleTask"
        android:parentActivityName=".HomeActivity"
        tools:ignore="UnusedAttribute"
        android:theme="@style/Theme.Startup"
        android:exported="true">

        <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.mysite.com"/>

            <data android:pathPrefix="/myPage"/>
            <data android:pathPrefix="/myFavourites"/>
       </intent-filter>
    </activity>

assetlinks.json 看起来没问题并且上传正确。但是所有应用链接仍然只在浏览器中打开,我看到,该应用支持该链接,但未选中。

还有命令 "adb shell pm get-app-links "com.myapp.android" 返回

com.myapp.android:
ID: 893......
Signatures: [13:03....DA]
Domain verification state:
  www.myapp.com: legacy_failure

为什么?请帮忙。

【问题讨论】:

  • 这似乎至少有一个问题in the Android issuetracker
  • 还有域验证状态:www.myapp.com: legacy_failure。会不会也是因为那些错误@Michael?

标签: android applinks android-12


【解决方案1】:

我确定您已经访问了以下链接:https://developer.android.com/studio/write/app-link-indexing

稍微改进清单以清理代码

<intent-filter android:autoVerify="true" tools:node="merge">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="${hostName}" android:pathPrefix="/auth/login" android:scheme="https"/>

检查您的assetlinks.json 文件https://DOMAIN.well-known/assetlinks.json

我遇到了 Apple M1 芯片的问题,一个在基于英特尔的机器上工作的链接,我的理论是 Android Studio 没有验证 M1 机器上的应用程序链接

【讨论】:

  • 是的,我都做了。但它仍然无法正常工作:)
【解决方案2】:

原因是文件语法不正确。 正确的是:

[
  {
    "relation": [
      "delegate_permission/common.get_login_creds"
    ],
    "target": {
      "namespace": "web",
      "site": "{siteurl}"
    }
  },
  {
    "relation": [
      "delegate_permission/common.get_login_creds"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.my.app.android",
      "sha256_cert_fingerprints": [
        "B4:...:9M"
      ]
    }
  },
  {
    "relation": [
      "delegate_permission/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.my.app.android",
      "sha256_cert_fingerprints": [
        "B4...9M"
      ]
    }
  },
  {
    "relation": [
      "delegate_permission/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.my.app.android.dev",
      "sha256_cert_fingerprints": [
        "BK...9Q"
      ]
    }
  }
]

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多