The Android app link is not working. I lost 5 days of sleep over this, from Monday to today .
What I did
- I uploaded the
assetlinks.jsonto my host,gifthub.kr, and it is accessible via https://gifthub.kr/.well-known/assetlinks.json.- There are three fingerprints. First one is from Play Console, second one is from
debug.keystore, and the last one is from my upload keystore file. - The
Content-Typeofassetlinks.jsonisapplication/json
- There are three fingerprints. First one is from Play Console, second one is from
- Then, I install my app through the
flutter runcommand, and when I openhttps://gifthub.kr/giftcards/deeplinkthrough Chrome, I was not directed to my app. - I searched and found that the app link doesn't work properly in debug mode. So I built it in release mode via
flutter build apkand installed it via Firebase Distribution on real device. However, when I tried to link the app in the same way afterwards, it didn't work. - I searched and searched and searched. And find a command to see if my address was linked to my app. And my app opened on my phone, not in Chrome or any other browser. It was my application.
adb shell am start -W -a android.intent.action.VIEW -d "https://gifthub.kr/giftcards/deeplink"
So I think
- I registered
assetlinks.jsoncoreectly via web deployment (As step 1) - My address is associated with the app correctly (As step 4)
But Why are the app link not work!
My files
AndroidManifest.xml
<meta-data
android:name="flutter_deeplinking_enabled"
android:value="true" />
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<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="gifthub.kr" />
<data android:pathPattern="/giftcards/deeplink" />
</intent-filter>
/.well-known/assetlinks.json
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "org.swmaestro.repl.GiftHub",
"sha256_cert_fingerprints": [
"CA:40:66:B3:4B:76:59:78:5F:32:7E:21:93:28:A5:76:F5:AF:E0:D6:15:6A:3B:6D:C0:08:35:56:3D:DC:D9:D7",
"F3:92:4F:BA:47:C3:20:0E:35:87:C5:3A:70:1C:6D:6E:C2:E5:31:1B:CE:C5:08:B5:44:44:29:0A:27:26:C0:88",
"E0:17:91:BD:A0:E7:23:F5:46:FC:62:03:4E:06:4A:CF:2A:9E:A7:53:40:BF:18:FC:15:EA:58:2D:80:E5:C2:C2"
]
}
}
]
My checklists
Check Digital Asset Links Validation: Is assetlinks.json correctly placed and accessible?
curl -v https://gifthub.kr/.well-known/assetlinks.json
< HTTP/2 200
< date: Sat, 11 Nov 2023 07:47:39 GMT
< content-type: application/json; charset=UTF-8
< content-length: 633
< accept-ranges: bytes
< cache-control: public, max-age=0
< last-modified: Thu, 09 Nov 2023 09:45:13 GMT
< vary: Accept-Encoding
<
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "org.swmaestro.repl.GiftHub",
"sha256_cert_fingerprints": [
"CA:40:66:B3:4B:76:59:78:5F:32:7E:21:93:28:A5:76:F5:AF:E0:D6:15:6A:3B:6D:C0:08:35:56:3D:DC:D9:D7",
"F3:92:4F:BA:47:C3:20:0E:35:87:C5:3A:70:1C:6D:6E:C2:E5:31:1B:CE:C5:08:B5:44:44:29:0A:27:26:C0:88",
"E0:17:91:BD:A0:E7:23:F5:46:FC:62:03:4E:06:4A:CF:2A:9E:A7:53:40:BF:18:FC:15:EA:58:2D:80:E5:C2:C2"
]
}
}
]
Review Android App Links Documentation: Do intent filters and metadata configurations set correctly in AndroidManifest.xml?
Flutter Documentation says
- Open the Flutter project with VS Code or Android Studio.
- Navigate to android/app/src/main/AndroidManifest.xml file.
- Add the following metadata tag and intent filter inside the tag with .MainActivity.
Replace example.com with your own web domain.
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" /> <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" android:host="example.com" /> <data android:scheme="https" /> </intent-filter>
And my meta-data and intent-filter are correctly placed in .MainActivity.
Check for Multiple Intent Filters: Check that there is only one deep link, so that it is not overshadowed by another filter that catches the URLs.
I have 5 intent filters, and there is only one for the android.intent.action.VIEW action.
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<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="gifthub.kr" />
<data android:pathPattern="/giftcards/.*/deeplink" />
</intent-filter>
Test with App Links Assistant: Try App Links Assistant to test the association and troubleshoot this issue.
App Links Assistant says my URL maps to .MainActivity correctly
Verify MIME Type: The assetlinks.json has correct MIME type application/json?
According to the curl result, the content type of assetlinks.json is application/json.
