AppLinks on Android 12 - opens browser only

Viewed 2672

I have the following manifest code:

<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 looks ok and uploaded correctly. But all applinks still opening only in browser, and I see, that app support the link, but it's unchecked.

Also command "adb shell pm get-app-links "com.myapp.android" returns

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

Why? Please help.

2 Answers

I'm sure you already visit the following link: https://developer.android.com/studio/write/app-link-indexing

Just a little bit improve your manifest to clean the code

<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"/>

Check your assetlinks.json file https://DOMAIN.well-known/assetlinks.json

I faced the issue with Apple M1 Chip an link working on intel based machines, I'm made the theory Android Studio not verifying the App Link on M1 Machines

The reason was in incorrect file syntax. The correct is:

[
  {
    "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"
      ]
    }
  }
]
Related