1

My Android App Links feature was not working until I added the meta-data tag:

<meta-data
android:name="asset_statements"
android:resource="@string/asset_statements"/>

Which is a suggestion I read here and here. However that is not mentioned by Google official documentation.

So... is it really needed or am I doing something else wrong?

(when I mentioned App Links was not working, I should note that deep link works but Android still displays the "default app chooser dialog")

Update #1: I'm testing on Android 8.1. I've uploaded the .well-known/assetlinks.json file. Here's my activity handling deep links:

<activity
    android:name=".LinkDispatcherActivity"
    <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="http" />
        <data android:scheme="https" />
        <data android:host="@string/www_app_domain" />
    </intent-filter>
</activity>
Ricardo Belchior
  • 576
  • 1
  • 3
  • 14
  • 1
    I have no such tag and haven't noticed any issues. Which Android version are you testing this on? What does your intent filter(s) look like? Have you done the necessary setup on your server for the verification to succeed? – Michael Nov 02 '18 at 09:03
  • see my update w/ details – Ricardo Belchior Nov 02 '18 at 11:15

2 Answers2

2

When you use that meta tag Android will validate "ownership" while the install. Only with that tag in your Manifest your app will be opened without any request. I'm talking about the chooser which app you would like to open to handle that url you defined in your manifest.

You can check this command to get the result of the validation, it may helps you to understand what went wrong:

adb shell dumpsys package domain-preferred-apps

See also the documentation regarding that: Verify Android App Links.

rekire
  • 47,260
  • 30
  • 167
  • 264
  • you are describing the App Links feature. Basically you're saying that is required to have App Links working. If that is the case, why does the official docs don't mention that? – Ricardo Belchior Nov 02 '18 at 11:28
  • Well I'm out of the topic for a while and I'm sure there is somewhere a reference that this is required. However it is also possible that they forgot it. If you are sure that this is really missing open a bug report that the documentation needs to be updated. – rekire Nov 02 '18 at 11:34
  • 1
    Perhaps it was required in the past but not anymore. I believe I found the problem, check my own reply to this issue. – Ricardo Belchior Nov 02 '18 at 11:38
2

Ok , after @Michael reply I think I found the reason why.

The website redirects http to https traffic. And once I remove the <data android:scheme="http" /> , I can comment the <meta-data> tag. In fact, in the docs they mention

Only if the system finds a matching Digital Asset Links file for all hosts in the manifest does it then establish your app as the default handler for the specified URL patterns.

I suppose that applies to all "hosts" and "scheme" as well, even though including the <meta-data> would kind of override that rule.

Thank you all for replying.

Ricardo Belchior
  • 576
  • 1
  • 3
  • 14