Android App Links
There are three kinds of links that can open an Android app:
- Custom schemes like
recipes://r/42: any app can claim the same scheme, and there’s no web fallback. - Web links (
https://…) with a plain intent filter: since Android 12, they open in the browser by default unless the app is verified, or the user manually allows it in settings. - Android App Links (the Android counterpart of universal linksUniversal linkAn https link that opens your app when it's installed and your website when it isn't.Open in glossary →): web links the app has proven it owns. They open the app directly, with no chooser dialog, and fall back to the website when the app isn’t installed.
Verification needs both sides:
- The app: an intent filter for the domain with
android:autoVerify="true". - The website: a file at
https://recipes.example.com/.well-known/assetlinks.jsonthat names the app’s package and the fingerprint of the certificate it’s signed with.
When the app is installed, Android downloads that file and checks that it matches. If it does, links to that domain open the app.
Like on iOS, an incoming link is input from outside: check it before using it, and only navigate, never act.
App Links verification is per domain: the manifest declares https intent filters with android:autoVerify="true", and each host serves /.well-known/assetlinks.json (HTTPS, no redirects, application/json) with delegate_permission/common.handle_all_urls for the package and its SHA-256 signing certificate fingerprints. With Play App Signing, that’s the app signing key shown in Play Console, not the upload key; debug builds have yet another fingerprint (list it for testing or use a debug-only domain). Since Android 12, unverified web intents go to the browser by default and users can enable links per app in settings; verification is retried in the background, and status can be inspected with adb shell pm get-app-links <package> and re-triggered with pm verify-app-links --re-verify. In Navigation Compose, navDeepLink on destinations builds the back stack for a link; for links that need authentication, route through a guard that stores the pending destination. Treat URIs as untrusted: validate host, path and ids, require explicit user confirmation for any state change, and never forward raw intents.
@Serializable data class RecipeRoute(val id: Long)
// Navigation Compose: the same destination handles taps and links
composable<RecipeRoute>(
deepLinks = listOf(navDeepLink<RecipeRoute>(basePath = "https://recipes.example.com/r")),
) { entry ->
val route = entry.toRoute<RecipeRoute>()
if (route.id > 0) RecipeScreen(route.id) else NotFoundScreen() // validate what came from outside
}<!-- AndroidManifest.xml -->
<activity android:name=".MainActivity" android:exported="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="https" android:host="recipes.example.com" android:pathPrefix="/r/" />
<data android:pathPrefix="/c/" />
</intent-filter>
</activity>// https://recipes.example.com/.well-known/assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example.recipes",
"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"]
}
}]autoVerify="true"asks Android to check the website’sassetlinks.jsonwhen the app is installed.sha256_cert_fingerprintsmust match the certificate the installed app is signed with. With Play App Signing, Google signs the app, so copy the fingerprint from Play Console.navDeepLinkconnects the URLhttps://recipes.example.com/r/{id}to the sameRecipeRoutethe app uses for taps, so links reuse normal navigation.- Validate: the id comes from a URL anyone can type, so check it before using it.
Tap the line with the bug.
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
val uri = intent.data ?: return
if (uri.path == "/account/delete" && uri.getQueryParameter("confirm") == "1") {
accountRepository.deleteAccount()
navController.navigate(GoodbyeRoute)
}
}Hint: Who can create this link, and who confirms the deletion?
Anyone can: a web page, an email, a QR code, another app. Opening the link deletes the user’s account with no confirmation from the user, based on a query parameter the attacker chose. That’s a destructive action triggered from untrusted input.
Links should navigate: open the account settings screen (after checking the user is signed in), where the user deletes the account with an explicit confirmation, ideally re-authenticating. The server must enforce its own checks too.
Production puzzles
Predict the output
assetlinks.json lists the SHA-256 fingerprint copied from the team's upload keystore. The app is distributed through Google Play with Play App Signing. What do users on Android 12+ experience when tapping links?
With Play App Signing, the APKs users install are signed by Google with the app signing key, whose fingerprint differs from the upload key. The website's file doesn't match the installed app, verification fails, and Android 12+ sends links to the browser. Add the app signing key's fingerprint from Play Console (and keep the upload key's only if you also distribute builds signed with it), then check with adb shell pm get-app-links.
Test App Links locally
You added App Links for recipes.example.com, but links still open the browser on your test phone. List the checks you’d do, in order.
›
Check each side of the verification, then what the device thinks.
SolutionTry it yourself first
- The file: open
https://recipes.example.com/.well-known/assetlinks.jsonin a browser: it must load over HTTPS, without redirects, as JSON. - The fingerprint: compare it with the certificate of the build you installed (
./gradlew signingReportfor debug and release; Play Console for Play-signed builds). - The manifest:
autoVerify="true",httpsscheme, the exact host,VIEW,DEFAULTandBROWSABLE. - The device:
adb shell pm get-app-links com.example.recipesshows the verification state per domain;adb shell pm verify-app-links --re-verify com.example.recipesretries it. - The test:
adb shell am start -a android.intent.action.VIEW -d "https://recipes.example.com/r/42"should open the app.
- App Links:
httpsintent filters withautoVerify,/.well-known/assetlinks.json(HTTPS, no redirects) with package + SHA-256 signing fingerprints. - Play App Signing: use the app signing key fingerprint from Play Console; debug builds differ.
- Android 12+: unverified web links open the browser; inspect with
pm get-app-links, retry withpm verify-app-links --re-verify. - Navigation Compose
navDeepLinkbuilds the back stack; auth guards stash pending routes; validate URIs; links navigate, never act.
Check this part
What makes a web link an Android App Link?
On Android 12+, what happens to an unverified https link the app declares?
With Play App Signing, which fingerprint goes into assetlinks.json?
A link should lead to a screen that needs login. What should happen for a signed-out user?