Quantcast
Channel: Yudiz Solutions Ltd.
Viewing all articles
Browse latest Browse all 595

A complete guide to Android Instant App

$
0
0

Overview

Android Instant Apps empowers local Android applications to keep running the android application without installing it in the android device.

Base feature module : The major module of your instant app is the base component module. All other element modules must rely upon the base element module. The base component module contains shared assets, for example, exercises, sections, and format records. At the point when incorporated with an instant app, this module constructs an element APK. At the point when incorporated with an introduced app, the base component module creates an AAR document.

Features : At an exceptionally fundamental level, apps have no less than one element or thing that they do: find a location on a map, send an email, or read the day by day news as cases.

Feature Modules : To give this on-request downloading of features, you have to separate your app into smaller modules and refactor them into feature modules.

Feature APKs : Each feature APK is worked from a feature module in your project and can be downloaded on request by the user and propelled as an instant app.

Each feature inside the instant app ought to have at least one Activity that goes about as the passage point for that feature. A section point activity has the UI for the feature and characterizes the general user stream. At the point when users dispatch the feature on their device, the entry-point activity is what they see first. A feature can have in excess of one entry-point activity, but it just needs one.

As you find in the figure, both “Feature 1” and “Feature 2” rely upon the base feature module. Thusly, both the instant and installed app modules rely upon the feature 1 and feature 2 modules. Each of the three feature modules are appeared in figure – base feature, feature 1, and feature 2 have the com.android.feature module applied to their build configuration records.

Step 1 : Install Instant App SDK

Manufacture an Android Instant App, we have to introduce the SDK. Go to Tools >Android > SDK Manager. Tap on the “SDK Tools” tab and introduce “Moment Apps Development SDK” by checking the crate and hitting “Apply”.

android-instant-image1

Step 2 : Android Source Code

In this progression, we will change over the existing application module into a shareable feature module. We will then make an insignificant application module that has a dependency on the recently framed feature. Note that this feature module will be incorporated into the Instant App build targets later.

Convert the app module into a feature module called base-feature :-

We start with renaming the module from ‘app’ to ‘base-feature’:

android-instant-image2

Change Module Type :-

Next, we change the module Compose to Feature module by changing the plugin from com.android.application to com.android.feature and furthermore evacuate applicationId because this is no longer an application module in the base-feature/build.gradle file.

// replace apply plugin: ‘com.android.application’
// with
apply plugin: ‘com.android.feature’

// remove application id
applicationId “com.instantapp.demo”

Specify base feature in the project base-feature/build.gradle

android {
    ...
    baseFeature = true
    ...
}

Create appapk module to build APK file :-

Now that we have changed our source code into a reusable library module, we can make an insignificant application module that will make the APK. From File->New Module

android-instant-image3

Enter application name “app apk”, leave supported module name (instantappdemo)

Replace compile dependencies in appaapk/build.gradle :-

dependencies {
    implementation project(':base-feature')
}

Change it back to “Android view” and remove the application component from appaapk/src/main/AndroidManifest.xml. It should just contain this single manifest component.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.instantapp.demo">
</manifest>

android-instant-image4

We have just moved the application’s core usefulness into a shareable feature module and we are now prepared to start including the Instant App modules.

Creating the instant app APK :-

android-instant-image5

The Instant App module is simply a wrapper for all the feature modules in your task. It should not contain any code or resources.

Create an Instant App module :-

Select File -> New -> New Module

android-instant-image6

Next, we have to refresh the instant app gradle document to rely upon the base feature module.

instantapp/build.gradle

apply plugin: 'com.android.instantapp'

dependencies {
   implementation project(":base-feature")
}

The instant app does not hold any code or resources. It contains just a build.gradle file.

Now must complete a clean rebuild: Build – > Rebuild project.

Defining App Links :-

Select Tools > App Link Assistant

android-instant-image7

Now tap on the “Open URL Mapping Editor” button.

android-instant-image8

Now tap the “+” button.

Create a new URL mapping.
Host: http://yudiz.com
Path: pathPattern, /mainactivity
Activity: .MainActiviy (base-feature)

android-instant-image9

You have to do same process if you have multiple mapping.

Now select the Run configuration dropdown and choose “Edit Configurations…”

android-instant-image10

Now select instantapp under Android App.

android-instant-image11

Replace the text ‘<<ERROR–NO URL SET>>’ with https://yourdomain.com/mainactivity

For mapping on the website browser you have to go and Select Tools > App Link Assistant

android-instant-image8

Now tap on the “Open Digital Assets Links file Generator”.

android-instant-image12

Now enter your Site Domain and Application ID

Then select either Signing config or Select keystore file.

Now tap on the “Generate Digital Assets Links file” button.

android-instant-image13

Now you get the signing file details like above image and you have to upload this file on your domain as a suggested path : https://yourdomain.com/.well-known/assetlinks.json (Your Domain Server must be running with the https(SSL)).

After uploading that on the server you have to hit the “Link and Verify”button.

android-instant-image14

If you are doing something wrong for file uploading on server then it will give you the error like below image.

android-instant-image15

After Verifying successfully. Now select instantapp from the Run configuration dropdown and click Run.

android-instant-image16

You’re done.

Step 3 : Test

Now you can see in the below video that instant app doesn’t get installed and show in the application menu.


Viewing all articles
Browse latest Browse all 595

Trending Articles