Android app link not working in android 12 always opening in browser

Viewed 15261

I have hosted assetlinks file into our domain https://ourdomain/.well-known/assetlinks.json And also verified this using https://developers.google.com/digital-asset-links/tools/generator and from android studio's App Links Assitant and got verified status from both the ways. But when i am sharing debug APK for testing it's always opening in browser. I also tried uploading on app store and downloaded from there for testing but it always open in browser.

Note: for debug build used my laptop SHA-256 and once app live on play store changed SHA ( got SHA-256from By going to Application Dashboard in Play Console then Release Management --> App Signing ) on hosted assetlinks file into our domain https://ourdomain/.well-known/assetlinks.json

Below is the code used in the manifest file.


     <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"
                android:host="abc.test.com" />
        </intent-filter>
8 Answers

Deep-links are working in Android 11 or before but on Android 12 it isn't.

But even after adding assetlinks.json file and adding all the intent-filters. Android 12 still isn't detecting deep-links. In Android-Manifest file turns out that scheme's tag is need to be separated from the data tag like this:

// OLD - Which is only working Android 11 or before

<data
  android:host="domain.name"
  android:pathPrefix="/videos"
  android:scheme="https" />

// NEW - Which is working on all including Android 12

<data android:scheme="https" />
<data
    android:host="domain.name"
    android:pathPrefix="/videos" />

In my case, the app is working in android 11, but it doesn't work in android 12 when the app is compiled and built with android studio.

I tested the production app; it works fine with the app link.

For development build, I have to go to App info -> Open by default -> Add link -> check off all the available links

This seems only happen with development builds; the apps installed from Google app store automatically has all the links selected.

After adding assetlinks.json in domain you have to reinstall app (just uninstall the app and install again) that will work

In my case problem was with inconsistent between SHA Signatures in store build and https://ourdomain/.well-known/assetlinks.json, that's why deep links were disabled by default on Android 12, for fixing it we can connect our phone with problem build to Android studio and run this command:

adb shell pm get-app-links com.your_app_package_name

as a result you should see something like this:

com.your_app_package_name:
ID: .....
Signatures: [AB:CD:EF:HI:GK...]
Domain verification state:
   your_domain.com legacy_failure

next you need to check whether the signature fingerprints is included in your https://ourdomain/.well-known/assetlinks.json, in my case it doesn't, also keep in mind that in assetlinks.json file can be couple of signatures for example for debug, alpha, beta and production builds, it should looks like below:

[
  {
   "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
     "namespace": "android_app",
     "package_name": "com.your_app_package_name",
     "sha256_cert_fingerprints" :["DE:BU:GS:HA:25:6...","PR:OD:SH:A:25:6..."]
        }
    }
]

This fixed it for me:

<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="my.page.link"  />
    <data android:scheme="https" />
        
</intent-filter>

Notice: android:autoVerify="true"

The weird thing about this is only broke on certain Android phones, and wasn't necessarily consistent across API versions. Pixel 4 on API 33 worked fine without this fix and didn't work with Pixel 6 on API 33. What can ya do.

In my case after doing the above (debug/release SHA-256 keys in assetlinks, separate the scheme tag) the final culprit turned out to be the "path" tag. For some reason the verification process does not include the tag even though this has always been there in the app and used to work prior to Android 12. Not a big deal in my app since I was ignoring the path anyway.

Before (not working):

<data android:host="dl.example.com"
      android:path="/test" />
<data android:scheme="https" />

After (working):

<data android:host="dl.example.com"/>
<data android:scheme="https"/>

Hope it helps someone

Related