56

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>
Asd
  • 561
  • 1
  • 4
  • 5
  • 6
    Go to your App Info -> Open by default -> Links to open in this app , and confirm that your app has your host abc.test.com as a verified link. – lyncx Nov 29 '21 at 01:22
  • Hello @lyncx i tested that way it's and working fine. But i do not want to do manually, please suggest if you have any other solution. – Asd Nov 29 '21 at 08:13
  • If the links are not being auto verified, then then problem is the SHA key is not correct. I had the same problem. Make sure your SHA key is correct and is matching your well-known/assetjson.link. Make sure you're downloading the app from the playstore if youre using the production SHA key – lyncx Nov 29 '21 at 11:11
  • Also verify if the link is https and not http – lyncx Nov 29 '21 at 11:12
  • @Iyncx Did you test on android 12 ? because on android 11 it's working as expected. – Asd Nov 29 '21 at 13:11
  • Yea its from android 12 that auto verification doesnt work if your SHA key is not correct. I was using the debug SHA key before and stopped working for devices that upgraded to android 12 – lyncx Nov 29 '21 at 23:18
  • 2
    @lynx Once my app is live on play store i went to Application Dashboard in Play Console then Release Management --> App Signing and got SHA256 from there and updated in well-known/assetjson.link. But still not working. Now my question is how you are getting SHA could you please suggest?? – Asd Nov 30 '21 at 11:41
  • If SHA256 from playstore matches your assetjson then it should work. Are you sure the link is not http? – lyncx Dec 01 '21 at 05:46
  • Hi Lyncx My link is https – Asd Dec 01 '21 at 08:53
  • @Asd Did you get this solved? I am facing the same issue. Working fine in Android 11 and not in Android 12. – Rethinavel Feb 08 '22 at 10:10
  • What `targetSdkVersion` are you using? It worked for us after updating to `targetSdkVersion = 31`. You could also try this: https://stackoverflow.com/a/68144368/1255553 – user1255553 Feb 10 '22 at 12:51
  • Try running the app in release build. As what the solutions here - https://stackoverflow.com/questions/68144323/app-links-legacy-failure-verification-error-on-android-12/69931886#69931886 , the sha256 fingerprint of debug & release keystore are different. – Joshua Feb 11 '22 at 03:39
  • 2
    https://stackoverflow.com/a/71676088/6341943 Since play console signing key is different from the signing key generated from android studio, both need to be added in the assetlinks.json. – hushed_voice Mar 30 '22 at 11:08
  • Hello @Rethinavel yes after updating the SHA in assetlinks.json file it's started work. If your app is on play store then you can get SHA by going play console->settings(sidebar)->App integrity->App Signingin – Asd May 14 '22 at 10:45
  • And if not then upload signed apk on play store and then get SHA by following above step and update in your assetlinks.json – Asd May 14 '22 at 10:47
  • In my case, only added https and removed http after assertlinks have the environment sha256. – Álysson Alexandre Aug 25 '22 at 11:25

11 Answers11

16

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.

Eric Cen
  • 3,616
  • 1
  • 13
  • 17
11

You need to add deep link verification. See https://doordash.engineering/2022/01/25/your-deep-links-might-be-broken-web-intents-and-android-12/

  • 1
    From this article I tried `android:autoVerify="true"` in my intent-filter and it fixed it – ICW Aug 03 '22 at 20:28
11

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

I have same problem and solved by going to app info setting -> set as default ->support web addresses and you will see your short link so turn it on and it will work ;)

Update:

as every one said its not a programmatically way so the best way is that link below said

Alireza Rabiei
  • 194
  • 1
  • 10
  • 4
    is there any programmatically solution? – Huy Nguyen Mar 10 '22 at 06:36
  • 12
    Trust me, it is not the proper way of resolving it from developer perspective. No one from users will do that so it is bad UX. – Mike Mar 24 '22 at 10:54
  • Asking the user to do it is not correct. The issue should probably be related to the SHA256 key we use in assetlinks.json. This is how I solved my issue https://stackoverflow.com/a/71676088/6341943 – hushed_voice Mar 30 '22 at 11:07
  • @hushed_voice the command is: `adb shell pm set-app-links --package [PACKAGE_NAME] 1 [URL_HOST]`, e.g. `adb shell pm set-app-links --package com.company.myapp 1 myapp.company.com` See: https://developer.android.com/training/app-links/verify-site-associations#manual-verification – User Rebo Apr 21 '22 at 14:48
  • And before Android 12 (<=API 30) it's: `adb shell pm set-app-link [PACKAGE_NAME] always` – User Rebo Apr 21 '22 at 17:35
  • @HuyNguyen i just update the answer – Alireza Rabiei Apr 27 '22 at 10:52
  • After you uploaded the file to the address that google said, you can validate your file with an API like below https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://example.com&relation=delegate_permission/common.handle_all_urls and happy coding ;) – Alireza Rabiei Aug 10 '22 at 04:39
7

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..."]
        }
    }
]
Orest Hredil
  • 175
  • 1
  • 7
  • thank you,I create assetlinks.json but I sha256_cert_fingerprints with gradlew signingReport command, but this not worked in release mode,worked on debug mode, but your solution is fine and work. – ff .n Dec 17 '22 at 05:17
  • Do you know why I got error "Unknown command: verify-app-links"? – Binh Ho May 04 '23 at 08:08
  • 1
    @BinhHo it looks like you are calling this command on an emulator/device with an Android version below 12 (API 31) Check here https://developer.android.com/training/app-links/verify-android-applinks#manual-verification – picKit Aug 29 '23 at 13:33
6

Before Android 12, Deep link followed the standard implementation with the code in the Manifest:

<intent-filter>
  <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="www.yourdomain.dev"
    android:pathPrefix="/set/v1" />

After Android 12, we have to add autoVerify to the intent-filter:

<intent-filter android:autoVerify="true" tools:targetApi="m">

And the website must be verified by adding assetlinks.json to the .well-known directory in your website (same as Apple does)

But, most important, you can only test this building and signing the app: Build -> Generate Signed Bundle/APK

during development, you can test your implementation manually enabling the link in the app on your device

  • 1
    Are you saying that now it is required to verify the website? Up till now we've always been able to just include the intent without verifying and having `assetlinks.json`. The only difference is the user will be given options on what to open the link with. If you verify then that option isn't given. In my case it is actually more preferable that users be shown the options... – Chris Feb 23 '23 at 16:30
  • 1
    Ok, yeah, looks like they made it mandatory in Android 12 https://developer.android.com/about/versions/12/behavior-changes-all#web-intent-resolution – Chris Feb 23 '23 at 16:35
  • 1
    @Chris yes, if you are using https, the website must be verified. That makes sense with the current trend of security Google and Apple are introducing – Fabio De Lorenzo Feb 24 '23 at 17:38
3

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

Vinay Rathod
  • 1,262
  • 1
  • 10
  • 19
2

Follow these steps:

Step 1:

Add android:autoVerify="true" to your intents-filter.

Step 2:

Move the android:scheme to separate data tag

So now your intents-filter in manifest looks like this:

<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="websiteUrl"
        android:pathPrefix="/" />
    <data
        android:scheme="https" />
    <!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>

Step 3:

Add your Digital Asset Links JSON file to following url:

https://{yourdomain.name}/.well-known/assetlinks.json

Note:- For production app make sure you use the digital asset links JSON file generated by Play console. You can find it at

Play console -> Your App -> Setup (Side menu option) -> App Integrity -> App signing (scroll to the bottom)

Step 4:

Verify that all the steps are correctly implemented by manually running app link validation using these commands - https://developer.android.com/training/app-links/verify-android-applinks#manual-verification

Step 5:

If your links were shown as verified in step 4 then now install the app on device and wait for atleast 2-3 minutes before clicking on any app links because in this time Android will verify your app links by reading your manifest file and the digital assets JSON file that you uploaded on your website.

After you have waited 2-3 minutes, now you can click on your app link and it should open your app.

Hope this helps!

Jay Mehta
  • 1,511
  • 15
  • 20
1

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.

ICW
  • 4,875
  • 5
  • 27
  • 33
1

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

Maaz
  • 173
  • 1
  • 2
  • 9
0

I have the same problem and everything is set up correctly, in my case the issue was that I was using nginx proxy server and Cloudflare, and I was blocking all countries from connecting to my server except Iraq (my country) you either have to disable the country restrictions or Allow some countries

like the following

Cloudlfare security rules

Ahmed Hnewa
  • 1,185
  • 1
  • 4
  • 14