# Android Web View & How To Generate APK

## Overview

This document will help us generate the APK for Citizen and Employee applications.

## Steps

### 1. Android Web View <a href="#id-1.-android-web-view" id="id-1.-android-web-view"></a>

Android offers a variety of ways to present content to a user. To provide a user experience that’s consistent with the rest of the platform, it’s usually best to build a native app that incorporates framework-provided experiences, such as [Android App Links](https://developer.android.com/training/app-links) or [Search](https://developer.android.com/guide/topics/search). Additionally, you can use Google Play-based experiences, such as [App Actions](https://developer.android.com/guide/actions) and [Slices](https://developer.android.com/guide/slices), where Google Play services are available. Some apps, however, may need increased control over the UI. In this case, a `WebView` is a good option for displaying trusted first-party content.

<div align="left"><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-e352a29709122fd292795d10c83548e990d79522%2Ffigure1.png?alt=media" alt="" width="340"><figcaption></figcaption></figure></div>

In Egov we create only responsive web apps instead of native apps (Android, IOS). The Android web view is used to render the out web application.

<div align="left"><figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-47acbf5953a8457664ecdb9434fa907c99b40857%2FScreenshot_2023-12-18-11-27-42-71_9751719c52650ee4605aed3597f307d8.jpg?alt=media" alt="" width="375"><figcaption></figcaption></figure></div>

### 2. Generate APK For Citizen & Employee Applications <a href="#id-2.-how-to-generate-apk-for-citizen-and-employee-application" id="id-2.-how-to-generate-apk-for-citizen-and-employee-application"></a>

1. Clone the [GitHub - egovernments/DIGIT-OSS: eGov Foundation's Open source repository of the DIGIT](https://github.com/egovernments/DIGIT-OSS) repo.
2. Open the below location in the [Android studio](https://developer.android.com/studio).

{% embed url="<https://github.com/egovernments/DIGIT-OSS/tree/master/frontend/mono-ui/web/rainmaker-webview>" %}

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-94a602d86c429442a70912adcba8b6fd4aebeb7b%2FScreenshot%202023-12-18%20at%2011.31.54%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

**Generate APK for citizen application**

1. Go to build. Gradle file there we have created multiple environments(UAT and PROD), please select the environment where you want to generate APK and put your web application URL.
2. Update the web application URL as required Application URL.

   `buildConfigField 'String', 'url', '"https://uat.digit.org/citizen/user/register"'`

   also, specify the citizen gateway hostname if not using Mastercard,

   `buildConfigField 'String', 'gatewayHost', '"migs.mastercard.co.in"'`

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-8840fdc52f827c8618f5d0f1f7ab9ddc4ec05d20%2FScreenshot%202023-12-18%20at%2011.35.46%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

3\. Save the file on the left side of the Android studio. Click Build Variants and select the applicable build variant.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-8563e178a229b53780385340ef5276e2a586933b%2FScreenshot%202023-12-18%20at%2011.37.35%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

4\. Click on **Build** menu, select **Build APK(s)** submenu.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-22912648ab29b5f7cc63ce378e7daa67d8278be1%2FScreenshot%202023-12-18%20at%2011.38.42%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

It will take some time to generate and it will show generated location.

**Generating APK for employee application**

1\. Go to build. Gradle file there we have created multiple environments (UAT and PROD), please select the environment where you want to generate APK and put your web application URL.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-8563e178a229b53780385340ef5276e2a586933b%2FScreenshot%202023-12-18%20at%2011.37.35%20AM.png?alt=media" alt=""><figcaption></figcaption></figure>

2\. Save the file, left side of the android studio click Build variants, and select build variant.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-2478814c1d3e2b7a4500ade6a951ddebfb5afd45%2Ffigure9.png?alt=media" alt=""><figcaption></figcaption></figure>

3\. Click on the build menu, and select Build APK(s) submenu.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-819466db2b9b78fdc42222aac1bf1ecca1e1e98d%2Ffigure11.png?alt=media" alt=""><figcaption></figcaption></figure>

It will take some time to generate and it will show generated location.

### 3. Generate APK For Production <a href="#id-3.-generating-apk-for-production" id="id-3.-generating-apk-for-production"></a>

1. Follow the 3rd and 4th steps mentioned above.
2. Click on the **Build** menu and select **Generate Signed Bundle / APK**.

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-808a7ecf4bdae1928a586c87c70ca7c943e57da9%2Ffigure10.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Select 1st radio button - **Android App Bundle.**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-629a785065ba429d77c2702254c977028310dae8%2Ffigure12.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Enter the information presented in the form and click on **Next.**

<figure><img src="https://3868804918-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FegsIWleSdyH9rMLJ8ShI%2Fuploads%2Fgit-blob-62a662701772a507d328dd11808cd15eac064e49%2Ffigure13.png?alt=media" alt=""><figcaption></figcaption></figure>

5. Upload the APK generated by the 4th step and upload it to the play store.

## Related Links

[How to debug android app using Chrome browser](https://docs.digit.org/platform/guides/developer-guide/ui-developer-guide/faqs/debug-android-app-using-chrome-browser)
