How to build PWA APK?

Updated 24 September 2023

Save

TWA (Trusted Web Activities):

Trusted Web Activities are a new way to integrate your web-app content such as your PWA with your Android app using a protocol based on Custom Tabs. A Trusted Web Activity runs a Chrome browser full screen in an Android app, meaning there is no browser UI visible in the app, including the URL bar.

Digital Asset Links :

TWA uses Digital Asset Links to certify ownership. The Digital Asset Links protocol and API enable an app or website to make public, verifiable statements about other apps or websites. For example, a website can declare that it is associated with a specific Android app, or it can declare that it wants to share user credentials with another website.

Steps to build PWA apk:

1. Add the Jetpack configuration in Project levelbuild.gradle. Under the allprojects section:

2. Add Java 8 features Module level build.gradle. Under the compileOptionssection:

3. Add the TWA Support Library to the project. Under the dependencies section:

4. Add TWA LauncherActivity to the AndroidManifest.xml.

5. Add  Digital AssetLinks statement to remove the URL bar.

We can generate assets links file from URL https://developers.google.com/digital-asset-links/tools/generator. If you will not configure Digital Asset Links JSON file properly then APK will show the URL bar.

Package Name:package_name”  is the value of the applicationId attribute.

SHA-256 Fingerprint: You can generate “sha256_cert_fingerprints” using below command in terminal
Release command “keytool -exportcert -list -v \-aliaskeystorealias -keystore keystorefile.jks”
Debug command  “keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android”

At the last put generated file at your host in the folder “.well-known“. It will be accessible publicly making a URL like this -> https://example.com/.well-known/assetlinks.json.

References:

https://developers.google.com/web/fundamentals/integration/webapks

https://developers.google.com/web/updates/2019/02/using-twa

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home