ANDROID INSTANT APP

MSApps
MSApps Development
Published in
5 min readDec 1, 2019

Have you ever thought about the idea to make people use your app instantly, without open your app listing on the Google Play Store and make them wonder if they should install it or not?

That idea is called ‘Instant App’ which developed by Google.
Android Instant Apps allows Android users to run your apps instantly, without installation,

Instant App is a good idea if you want to let people try part of your app and if they do like it they can download it and enjoy the app as is with its full features and screens.

Or if you want to try your app for a single purpose, pay for a parking ticket for example.
Users can get to your app from any URL — including search, social media, messaging, and other deep links — without needing to install your app first.
And if you wonder how the user experience would be, this is not an issue at all, because Instant Apps runs natively and smooth.

As you read previously, Instant app runs in response to launching a URL,
So how it works exactly?

When Google Play receives a request for a URL that matches an instant app, it sends the necessary code files to the Android device that sent the request. The device then runs the app.

The URL which launches instant app must be using HTTPS, Instant apps do not support HTTP.
Each activity launches by a different route, keep reading, it will be much clear.

To create an instant app you need to follow:

  • Android Studio version 3.0 or later
  • Android SDK Build Tools 26+
  • Android SDK Tools 25+
  • Android SDK platform O
  • Latest Android Support Library
  • Latest Android Repository

Android Instant Apps uses the runtime permissions model that was introduced in Android 6.0 (API level 23).
The instant app also need to break up the app into smaller modules and refactor them into feature modules.
When making an APK for the instant app, the build output is Instant App APKs that contain one or more feature APKs.

Each feature APK is built from a feature module in your project and can be downloaded on demand by the user and launched as an instant app.

Every instant app must have one base feature APK, which includes all the configuration of the app, and the other modules kind of inherit the configurations from the base feature.

Instant App APK

As mentioned, your URL must be using HTTPS to launch your app, If you don’t have an HTTPS domain, I think that the best and easiest solution to getting one is by Firebase hosting service.

Firebase hosting service provides hosting with an HTTPS domain which exactly what we to make the instant app launch. When you make a new project on Android Studio make sure you enable ‘include Android Instant App support’ checkbox.

In the configure activity screen you need to provide the URL host(which must be HTTPS), Instant app URL Route, which launch the activity you want in the text input field (Activity name)

Configure the activity with the App URL and URL route for the instant app.

After finish all the configurations you need to defining entry points for your app
You need to use URL entry points or deep links to launch instant app from a URL,
In the manifest file you need to configure it like the following example:

a snippet from the manifest file that defines an entry-point activity and default URL for an instant app.

* If you wonder why we include HTTP although that All the network traffic from inside instant apps must use HTTPS. this is because that all declared intent filters in your instant app must support both HTTPS and HTTP protocols.

There is an App Links Assistant which can help you configure the entry point and the URL’s in your app.

Part 3 in the App Links Assistant, associate the website (From firebase for example) by generating a digital asset links file which is a JSON file called ‘assetlinks.json’.
You need to upload that file to your website in a folder named ‘.well-known’.

for example https://example.com/.well-known/assetlinks.json
(if you trying to make the .well-known folder and rejected because its name starts with dot,
Try to make it that folder in the terminal by the command ‘mkdir .well-known’ on both Windows or Mac operating systems, and it might be hidden after creating it.

* Try to add Firebase Dynamic Links, which much recommended when making instant apps to guarantee that clicks on your links always take users to your instant app, and to track statistics on link events.

You can generate the assetlinks.json file for debug and release modes.

After uploading the file to your website, click on the ‘Link and Verify’ button to test it.
You can test it also on ‘https://developers.google.com/digital-asset-links/tools/generator’
by providing the hosting site domain, app package name, and the app package fingerprint that can be found in the assetlinks.json file.

Step 4 in the App links assistant is to make sure that the corresponding route launches the activity you want and test it on the device or emulator.
If everything is verified and tested successfully you can build an APK for the base App and the instant app.

When selecting Generate Signed APK, you will be asked to choose the module,
one for the app itself and the other for the instant app.
Android Studio will create a zip file with the APK of your modules when trying to generate a signed APK for the instant app.
In Google Play Developer Console, upload the app APK and then, in the Instant app section, upload the zip file.

After Google approves the app, check the instant app by sharing the URL (with Google Allo or WhatsApp for example) with the route as the entry point which launches the activity you configured in the Manifest file.

I know that lots of things must be done to make an Instant App, but at the end of it, it worth all the effort.

--

--