Android App Links: Deploy assetlinks.json in minutes

Sabs
Android Developers
Published in
4 min readApr 11, 2023

--

Goal: Provide an efficient way to deploy your Google Digital Asset Links (DAL) file in order to ease the verification process for Android App Links

Introduction

The Android App Link verification process requires control of a specific path on a web host, which makes it challenging for an Android developer to test without cooperation from the manager of their website. This blog post aims to help Android developers quickly create a domain that will allow you to successfully deploy the assetlinks.json file and verify their Android App Links in a developer or test environment.

In this blog post we will present 2 simple ways to deploy the assetlinks.json file into a website:

Android App Links Requirements

To successfully deploy a test domain for Android App Links, let’s review what we need for assetlinks.json:

  • It must be publicly available, and not behind a VPN.
  • It must be served with Content-type: application/json.
  • It must be accessible over HTTPS.
  • It must be served directly with an HTTP 200 response (no HTTP 300’s redirect).

With these requirements in mind, we are ready to set up our test domain.

Firebase

This section will help you deploy assetlinks.json with Firebase Hosting. Please refer to the Firebase Hosting documentation for details on the commands and steps.

*Note: All the commands that will be presented will work on MacOS/Linux.

Step 0: Prerequisite

  • Firebase CLI: Please check the docs on how to install depending on your OS, then run firebase login

Command:

Step 1: Initialize firebase project

Command:

1.1 Select “Create a new project”

1.2 Specify a globally unique project ID. It can be any string from 6–30 chars. We will use “deeplinks-test”

1.3 Recommended: have the same name for the project ID and the beginning of the domain name

1.4 Recommended: leave all defaults for public directory (public), single-page app (No), and automatic builds (No)

Step 2: Add assetlinks.json

Command:

2.1 This command creates a “.well-known/” directory and creates the “assetlinks.json” file that contains the empty array “[]”. The default Firebase Hosting configuration will deploy files in your public/ directory.

Step 3: Deploy

Command:

3.1 Let’s verify that our website is deployed and the assetlinks.json file is in place

3.2 The command will show the deployed website URL in the form “https://<PROJECT_ID>.web.app”

3.3 Navigate to “https://<PROJECT_ID>.web.app/.well-known/assetlinks.json”

3.4 Make sure you see “[]”

You’ve successfully deployed assetlinks.json! You can now edit the contents of the file public/.well-known/assetlinks.json and deploy updated configurations. You’re ready for the section “What’s Next?” below.

GitHub Pages

This section will help you deploy assetlinks.json with GitHub Pages. Please refer to the GitHub Pages documentation for details on the steps.

Step 0: Prerequisite

  • You can install git or GitHub desktop client, or use GitHub UI

Step 1: Create a repository

1.1 Create a new repository. Make sure the repository name is using the following format:

“<username>.github.io”. We need to update “<username>” with your github username. For example: sabs231.github.io. Note: You can have 1 GitHub page per repository, user and organization. Check the documentation for more details.

Step 2: Clone repository

Command:

2.1 Make sure “<username>” is replaced by your Github username.

Step 3: Add assetlinks.json

Command:

3.1 This command creates a “.well-known/” directory and creates the “assetlinks.json” file that contains the empty array “[]”.

Step 4: Push it to main branch

Command:

4.1 This commands adds the added files/directories, commits them and pushes to the main branch

Step 5: Verify

5.1 Go to “https://<username>.github.io/.well-known/assetlinks.json” and verify you see the “[]”

You’ve successfully deployed assetlinks.json! You can now edit the contents of the file .well-known/assetlinks.json and deploy updated configurations. You’re ready for the section “What’s Next?” below.

Other Options

There are many options to deploy your website, from running it in your own hardware to renting it from a public cloud. Each with their own level of complexity, we suggest reviewing their documentation and make sure they have the listed requirements for Android App Links.

Summary

We presented 2 options for configuring and deploying a website with the assetlinks.json file.

Hopefully, it will ease the configuration of the test environment for Android App Links so they can be verified efficiently

What’s Next?

To successfully verify your Android App Links we suggest the following steps:

  • Declare the website association in your deployed “assetlinks.json” file
  • Verify manually if the Android App Links was successfully verified
  • Check our crash course video series for more

All these steps and more are discussed in our codelab for Android App Links.

--

--