App Link not opening in Android 12 by default. Possible SHA256 issue
Asked Answered
K

4

16

I have set up my deeplink by uploading the assetlinks.json file here

https://example.com/.well-known/assetlinks.json

Its working well till Android 11. It also works in Android 12 if it's not downloaded from Playstore(ie installed from my android studio or from a apk file I made from android studio, works even when I sign the apk file with Keystore.)

When it is downloaded from playstore on Android 12, if you go to App settings->Open by default->Links to open in app. We can see that my domain is disabled by default. I think it has something to do with the sha256 I used in assetlinks.json

I got my assetlinks.json from App Link Assistant in Android studio.(I selected my keystore file also while generating the asssetlinks).

If I go to my play console->Setup->App integrity->App signing

I can see a different Sha256 in the Digital Asset Json section(which is also in App signing key certificate section)

I can see the Sha256 I uploaded in the Upload Key certificate section.

My question is which sha256 should I use in assetlinks.json?

I have seen here that I should use both. If I should, how can I add both the sha256 in my assetlink.json. Can I just add it as a comma separated values like this??

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example",
    "sha256_cert_fingerprints":
    ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5", "NE:XT:SH:A2:56:VA:LU:ER..."]
  }
}]

I want the deep links to work both in debug as well as release builds.

Kilmarnock answered 29/3, 2022 at 15:1 Comment(0)
K
14

Finally figured out the issue after spending hours figuring it out.

Basically, if you are using the google app signing key that Google uses to sign each of your releases, you need to add the SHA256 from the play console also to the assetlinks.json file for your domain to be verified automatically on the play store app.

This issue was never found out because the signing key used for the non-app store build (testing build) was different, which I got from the Android studio App link assistant

The final assetlinks.json looks something like this :

[
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.android",
      "sha256_cert_fingerprints": [
        "SH:A2:56:FR:OM:PL:AY:CO:NS:OL:EX:......"
      ]
    }
  },
  {
    "relation": ["delegate_permission/common.handle_all_urls"],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example.android",
      "sha256_cert_fingerprints": [
        "SH:A2:56:FR:OM:AN:DR:OI:DS:TU:DI:OO......"
      ]
    }
  }]

In my case the playstore build was already published. When I released a new update with few other bugfixes, the new updates had the deeplink automatically verified.

Kilmarnock answered 30/3, 2022 at 11:5 Comment(5)
Hello, we work on signed app in all our environement, and we have issue everywhere on android 12, it does not depend of the sha256 which are correct for all env, our configuration passed the google check but we have legacy_failure only on android 12, are you sure that this helped ? To me it's seems it started to work without reason.Featherbedding
Yes. You can go to play console->settings(sidebar)->App integrity->App Signing to verify if it is the same as the one uploaded in the assetslinks.json. If it is same, this should not be your issue.Kilmarnock
Is any thing depend on how i answer question in "keytool -genkey" command like "organizational unit" and "organizational" and "City or Locality" and etc ? Is it was same package name (that is in my case com.sepan.mrAnti.mr_anti) ?Fenwick
I check my sha256 with play console but it's still not working i test on QA environment. it's working after release this app ??? and it's still working on android 11Futch
@Kilmarnock I'd like to like your anwser multiple times. Thank you so much for freeing me from the pain of being still strucked with this issue.Outbuilding
D
11

This was my problem too.
Answer below saved my hours

Turns out that if you break

<data android:scheme="http" android:host="www.example.com"/>

into 2 tags

<data android:scheme="http" />
<data android:host="www.example.com" />

in AndroidManifest.xml, the app link will get verified successfully on Android 12. This change also seems backward compatible on older versions of Android, even though the documentation didn't say so explicitly.

Answer reference

Deposal answered 24/5, 2022 at 11:1 Comment(2)
how to test this ??Preterhuman
I had the same problem and I tried to use the proposed solutions, but it didn't work. I used the redirect from my site replacing the "https" scheme with the one of the app configured in the intent and it works fine. From "https://..." to "myapp://..." it could be done also with redirectUrl implemented server sideKasper
C
1

In my case after doing the above (all SHA-256 keys in assetlinks, separate the scheme tag) the final culprit turned out to be the "path" tag.

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

Cockpit answered 1/9, 2022 at 23:59 Comment(6)
how to test it ??Preterhuman
@Preterhuman In Android Studio you can test it by following Tools > App Link Assistant > Open URL Mapping Editor > And entering your complete URL in Check URL Mapping.Meijer
@vikash-sharma in App Link Assistant It needs to in "add URL mapping" the activity drop box is empty and nothing add !Fenwick
@Fenwick may you describe what are you trying to achieve and how are you doing it. Since one of your Activity class should be capable of listening the App Link requests.Meijer
@vikash-sharma please see this https://mcmap.net/q/749269/-android-studio-app-links-assistant-does-not-show-and-activity/3600935 thanks a lotFenwick
<activity android:name=".act.ActSplash" android:exported="true"> <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:host="example.com" android:scheme="https" /> </intent-filter> </activity> This is a sample to tell Android that which class will act to handle App Link.Meijer
C
0

Check your https://{domain}/.well-known/assetlinks.json.

Once you hit this URL on the browser it should open the json file on the browser and not download the json file. If it downloads then fix it from the server.

Cide answered 11/7 at 8:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.