What are the changes need for working deeplink in Android 12

7.3k Views Asked by At

The deep linking feature of my app was working fine with Android 11. But it is not working in Android 12. I checked and followed several StackOverflow posts and some other blogs. But I am getting the links unchecked in the app details

enter image description here

If I manually check it, the deep linking will work.

I tried manual verification by using the documentation and getting legacy_failure error. https://developer.android.com/training/app-links/verify-site-associations#manual-verification

I followed this URL too https://doordash.engineering/2022/01/25/your-deep-links-might-be-broken-web-intents-and-android-12/comment-page-1/?unapproved=40015&moderation-hash=dc9e7df0845c5072330edc78f75ca497#comments .

1

There are 1 best solutions below

0
On

This approach should solve deeplink issue on android 12 above

Automatic approach

skip step 1 & 2

Go to Tools/ App Link Assistance and follow the step on the image

enter image description here

Manual Approach

Step 1: update all intent filters that can respond to an HTTP link with the android:autoVerify="true"

<activity
android:name="com.example.MainActivity">
    <intent-filter android:autoVerify="true">

    </intent-filter>
</activity>

Step 2: Create the assetlinks.json file and update your package and sha key

  //update package_name and sha256_cert_fingerprints with yours
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
  "namespace": "android_app",
  "package_name": "Your App’s package name", 
  "sha256_cert_fingerprints":  ["Your App’s SHA256 finger print"]
 }

}]

Step 3: Publishing the JSON verification file Work with your infrastructure team to deploy the assetlinks.json file to the host

https://your domain.com/.well-known/assetlinks.json

Be sure of the following:

  • The assetlinks.json file is served with content-type application/json.
  • The assetlinks.json file must be accessible over an HTTPS connection, regardless of whether your app's intent filters declare HTTPS as the data scheme.
  • The assetlinks.json file must be accessible without any redirects (no 301 or 302 redirects).
  • Do not publish your app with dev/test URLs in the manifest file that may not be accessible to the public (such as any that are accessible only with a VPN). A work-around in such cases is to configure build variants to generate a different manifest file for dev builds.