App links intent filters in assetlinks.json not working on Android
Solution 1:
For us it was Windows line endings!
Testing with "https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls" proved invaluable as it gave us an "Could not parse statement list (not valid JSON)" error which led us to the problem.
TIP: It was good to use the 'Save File' button in the Android Studio App Links Assistant instead of copying and pasting as we did - that way it generates the file itself and is guaranteed not to have this issue.
Solution 2:
There are some common pitfalls which you should check twice (I don't say that you did it wrong. It is just a check list):
- Verify that the
assetlinks.json
is valid and stored accessible fromhttps://example.com/.well-known/assetlinks.json
to do that you need to visithttps://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site= https://example.com&relation=delegate_permission/common.handle_all_urls
, there must be no errors. - If you link multiple domains at once, check that all domains are setup correctly as in step 1.
- Make sure that those
<intent-filters>
which contain your<data>
tags have the attributeandroid:autoVerify="true"
. -
Verify that you have the required
<meta-data>
tag in your<application>
tag:<meta-data android:name="asset_statements" android:resource="@string/asset_statements"/>
The content of the
asset_statements
string must be:<string name="asset_statements" translatable="false">[{\"include\": \"https://example.com/.well-known/assetlinks.json\"}]
-
Use for debug also the release signing certificate (don't be scared you cannot upload it accidentally) use this in your
build.gradle
:buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { debuggable true signingConfig signingConfigs.release } }