# Setup

### Repositories

{% embed url="<https://github.com/mosip/inji-wallet>" %}

### Prerequisite

* [Gradle](https://gradle.org/install/)
* [Java 17](https://www.oracle.com/ph/java/technologies/downloads/#java17)
* [Expo](https://docs.expo.dev/home/get-started/installation/)
* [Android SDK](https://developer.android.com/)
* [Node](https://nodejs.org/en/download)
* [XCode](https://developer.apple.com/xcode/) for iOS development

To perform **offline sharing using BLE**, we recommend below:

* Devices with Bluetooth v4.2 and above
* Android v23 and above for Android

## Android - Build and Run

The below sections describe the steps for building the android application in Mac and Windows OS.

### 1a. Installation and Keystore generation on MAC

#### Step 1:

Configure Node & npm (recommended to use v16.19.0)

```
brew install nvm

nvm install 16.19.0

nvm use 16.19.0
```

#### Step 2:

Configure Yarn

```
brew install yarn
```

#### Step 3:

Configure Gradle & Java

```
curl -s "https://get.sdkman.io" | bash

sdk install gradle 7.5.1

sdk install java 17.0.13-amzn
```

#### Step 4:

Configure Expo, refer [here](https://docs.expo.dev/get-started/installation/).

#### Step 5:

Configure Android SDK, refer [here](https://developer.android.com/).

Configure environment variables in your `~/.zshrc /` or `~/.bashrc` (depending upon your shell)

```
export ANDROID_HOME="$HOME/Library/Android/sdk"

export ANDROID_PLATFORM_TOOLS="$ANDROID_HOME/platform-tools"

export ANDROID_CMDLINE_TOOLS="$HOME/Library/Android/sdk/cmdline-tools/latest/bin/"

export PATH="$PATH:$ANDROID_PLATFORM_TOOLS:$ANDROID_CMDLINE_TOOLS"
```

#### Step 6:

Generate debug keystore for building debug build.

```
keytool \
 -genkey -v \
 -storetype PKCS12 \
 -keyalg RSA \
 -keysize 2048 \
 -validity 10000 \
 -storepass 'android' \
 -keypass 'android' \
 -alias androiddebugkey \
 -keystore android/app/debug.keystore \
 -dname "CN=io.mosip.residentapp,OU=,O=,L=,S=,C=US"
```

Export keystore

```
export DEBUG_KEYSTORE_ALIAS=androiddebugkey

export DEBUG_KEYSTORE_PASSWORD=android
```

### 1b. Installation and Keystore generation on Windows

#### Step 1:

* Install Git
* Use the below link to download git

```
https://git-scm.com/download/win
```

* After installation, run Git as admin.

#### Step 2:

* Install SDKMAN
* Use the below command in Git terminal

```
curl -s "<https://get.sdkman.io>" | bash
```

* If you encounter an error while installing sdkman, please install zip on your system using your favourite package manager.

**Install zip**

1. `SDKMan` requires the installation of the zip utility, which is not included in the default installation of Windows Git Bash.
2. To address this, please visit the [website](https://sourceforge.net/projects/gnuwin32/files/).
3. Locate **zip** in the list of available files and download the **zip-3.0-bin.zip** archive. Extract the **zip.exe** file from the archive and place it in the **bin** folder. Location of bin folder `C:\Program Files\Git\usr\bin`.
4. Finally, rerun the `SDKMan` installation script.

#### Step 3:

* Install gradle
* Use the command below in Git terminal.

```
sdk install gradle 7.5.1
```

* To check the installed gradle version.

`gradle -V`

#### Step 4:

* Install Java JDK, refer [here](https://www.oracle.com/ph/java/technologies/downloads/#java17).

```
[!TIP]
Restart system
```

#### Step 5:

* Install expo

```
npm install --global expo-cli
```

#### Step 6:

* Install Android SDK, refer [here](https://developer.android.com/).

#### Step 7:

* Install Node, refer [here](https://nodejs.org/en/download).

#### Step 8:

* Install nvm

```
curl -o- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh> | bash
```

or

```
wget -qO- <https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh> | bash
```

update the nvm version

```
nvm install 16.19.0
nvm use 16.19.0
```

#### Step 9:

Install adb

```
https://sourceforge.net/projects/quickadb/
```

Configure ANDROID\_HOME and JAVA\_HOME in system environment variables

### 2. Command to build the application

#### Step 1:

* Clone Inji repository.

#### Step 2:

* Create an `android/local.properties` file with the following data:

```
sdk.dir = <location-of-the-android-sdk>
```

* Alternatively, you can open the Android folder in the android studio. It will create `local.properties` file with `sdk.dir = <location-of-the-android-sdk>`.

> Note:
>
> * Default path for MacOS: `/Users/<username>/Library/Android/sdk`
> * Default path for Linux: `/home/<username>/Android/Sdk`
> * Default path for Windows: `C:\Users\<username>\AppData\Local\Android\sdk`

#### Step 3:

* Inji application currently supports two themes: **gradient** and **purple**.
* The default theme of the app is gradient.
* To change the theme of the application, go to `.env` file and change the value of `APPLICATION_THEME` to `purple` or `orange` to apply gradient theme

#### Step 4:

* Update mimoto url as <https://api.collab.mosip.net> [here](https://github.com/mosip/inji/blob/main/.env#L5)
* Update esignet host as <https://esignet.collab.mosip.net> [here](https://github.com/mosip/inji/blob/main/.env#L7)
* To deploy mimoto in local refer [here](https://docs.mosip.io/inji/inji-mobile-wallet/build-and-deployment/local-setup#how-to-run-this-setup)

#### Step 5:

* Go to the root folder of the project in the terminal.
* Install all the dependencies using `npm install`.

#### Step 6:

**Build and run the application on the device:**

* Run `npm run android:mosip` to build and install the application on the device.
* Run `npm run android:mosip --reset-cache` to build and install the application if any change is made in the .env file.

### 3. Troubleshooting

If you encounter the below issue on Windows,

```
**FAILURE:** Build failed with an exception.

**Where:**
  Script 'C:\....\inji\node_modules\expo\scripts\autolinking.gradle' line: 2

**What went wrong:**
  A problem occurred evaluating script.
  > Could not read script 'C:\"PATH"\inji\node_modules\expo\scripts\android\autolinking_implementation.gradle' as it does not exist.
```

* Run `npm i expo-modules-autolinking@~1.1.0` and rebuild the app
* Path for debug apk in Inji directory `android/app/build/outputs/apk/mosip/debug`

### 4. Setting Up Google API Services and Client ID for Data backup & Restore

#### Step 1:

**Creating A Google Cloud Project** Refer to this documentation on setting up a Google Cloud Project - <https://developers.google.com/workspace/guides/create-project>

#### Step 2:

**Enabling Google Drive APIs** Go to - <https://console.cloud.google.com/apis/library>

![GCP API Library](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-83b10b93614b0ab8ae89bede7b996eedfc15f4ad%2Fgcp-api-libs.png?alt=media)

Search for `Google drive API` and Select Google Drive API from the list.

Then enable the API.

![GCP Drive API Enable](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-82b4834dbe5a4cba33d85e13fd7307f1c3461ee6%2Fdrive-api.png?alt=media)

#### Step 3:

**Create Google Consent Screen**

Go to - <https://console.cloud.google.com/apis/credentials/consent>

Create a new Consent Screen with necessary details such as - App Name, User Support Email, App Logo and Developer Info. Once added these details Save and Continue.

#### Step 4:

**Create Oauth Client ID**

Go to - <https://console.cloud.google.com/apis/credentials>

![GCP Create Client ID](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-02a728a5b9f547388364fa52ef57cc2d9150f030%2Fcreate-CID.png?alt=media)

Click on `CREATE CREDENTIALS` and choose `OAuth client ID`

![GCP Create Client ID](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-e357000fe6be975391815ec4ffe26af6f9006054%2Fapplication-type.png?alt=media)

Choose Appliation type as `Android`

![GCP Create Client ID](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-77eefda0256e5b2dc32c44c59de3dba66e893f49%2Fcid-details.png?alt=media)

Add in details such as *Name*, *Package Name* and *SHA- Fingerptint*

> Note:
>
> * SHA-1 should be of the keystore generated for signing the APK
> * Make sure you have checked `Custom URI Scheme` in `Advanced Settings`
> * The APK signing keystore needs to be unchanged for backup feature to work as the SHA-1 is 1-1 mapped for a client ID created

#### Step 5:

**Set Environment Variable**

Once the Client ID has been created copy the client ID and add it as part of `.env` file.

`GOOGLE_ANDROID_CLIENT_ID="<copied-client-id>"`

### 5. Build for PlayConsole

The Internal testing version of the build can be uploaded to `PlayConsole` for testing. PlayConsole allows the creation of internal testers group.

![Internal testers](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-16cb7383696356a0082bb102333b475999c08c52%2Finternal_testers_android.png?alt=media\&token=e9273c43-2c88-44ad-8e0b-485265f95c23)

**Publishing build manually to PlayConsole**

A Google play console developer account is a must to publish builds in PlayConsole.

1. Set the backend URL and choose a theme (orange | purple) inside the `.env` file.
2. Build the Apk or App bundle.
3. Login to PlayConsole and create a new release inside Internal testers.
4. Upload the Apk or App bundle to PlayConsole.

**Upload in PlayConsole**

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-21d6229f477f0b20907332ccbd6cad43fdf47c9c%2Fupload_android.png?alt=media\&token=509a85ec-19bb-43bf-b29e-9a4e0640b385)

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-7689a72f51bb5c5ac5e68fa99d2e0d11595350d7%2Fuploading_android.png?alt=media\&token=4273fe57-877e-42d6-8308-eac09f4ba15c)

1. Once the build is uploaded and saved you will be able to see the status of the release with version name, code, API level and some more details.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-19974a3db4aac732a814f883fd29ab2969ebb253%2Fuploaded_view_android.png?alt=media\&token=70d31e4b-1d4a-46b5-839a-92f17da10895)

2. Select the testers group you want to share with. Once saved, you can copy the link and share the same with the testers to test the APK or App bundle.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-8dd64ece28e0aebb7771d9288eac08636c031a59%2Finternal_testers_select_android.png?alt=media\&token=9af56eba-7ca5-473f-91ff-109a64be7ade)

3. You are required to manually share the link with the testers as they will not receive any notifications when a new build is uploaded.

**Publishing build via Github actions (Automation) to PlayConsole**

1. A Google PlayConsole developer account must be configured to Inji to publish builds via PlayConsole.

> Testers must be added to internal testers group in Play console.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-8dd64ece28e0aebb7771d9288eac08636c031a59%2Finternal_testers_select_android.png?alt=media\&token=9af56eba-7ca5-473f-91ff-109a64be7ade)

2. To deploy the Android build to PlayConsole, select `Android Custom Build` workflow from github actions.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-d16be69e5a0e9635f513fda53ff5940d84d96db6%2Finji_android_github_actions.png?alt=media\&token=22898e2f-c977-4c4c-bebf-78663ce7f06b)

3. Choose the branch, backend url, theme and describe about build details.
4. Click the `Run` workflow button.
5. Once the pipeline has done with building the app (takes around \~25-30min), you need to login to PlayConsole and verify the build version name and code in the internal testers track.
6. Now, you can share the link to testers.

***Note***: Only those who are registered in the selected testers group will be able to download the App from Google Play.

***

## iOS - Build and run

The below section describes the steps build the iOS application.

### 1. Installation and Keystore generation

#### Step 1:

Follow the [Steps](#installation-and-keystore-generation-on-mac) to configure Node & npm, Expo and generate debug keystore

#### Step 2:

Configure XCode, refer [here](https://developer.apple.com/xcode/).

#### Step 3:

Enable iCloud and create Containers, refer <https://developer.apple.com/help/account/manage-identifiers/create-an-icloud-container/>

### 2. Build process

* Install all the dependencies

```
npm install
npx pod-install
```

* Run Metro bundler in the background

```
npm start
```

* Run Inji directly to a connected device Command to run on simulator

```
npm run ios
```

Command to run real device

```
npm run ios -- --device
```

### 3. Build for TestFlight

The beta version of the build can be uploaded to `TestFlight` for testing. TestFlight allows the creation of internal and external testing teams who will be notified once a new build is published.

![Testflight testers](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-71bcd3a0f548d702cee6d71e100210551d1a054c%2Fimg.png?alt=media\&token=3f10475d-fbbb-4295-910c-117a3386b020)

**Publishing build manually to TestFlight**

An Apple developer account is a must to publish builds in TestFlight.

1. Set the backend URL and choose a theme (orange | purple) inside the `.env` file.
2. Archive the build using `xcode`.
3. Upload the archive to Testflight.

First choose `Distribute App`.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-1d7b6e6c8688ff052d5598459c16d45fee0b5088%2Farchive.png?alt=media\&token=3d0e4f09-9c51-4f2c-b110-0ec11b32e0cb)

**Upload in TestFlight**

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-d2ea0e2256d78f89116de2d88e673441713868e6%2Fupload.png?alt=media\&token=5434bf31-dda5-4f1f-b923-9c2474de8815)

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-67f8528adf4db4dfe00815731038f8ab0cbc5f3b%2Fuploading.png?alt=media\&token=ddd42cdb-1b5a-47f3-b812-87d25eff41a7)

1. Login to TestFlight and check for the build upload status. Once the build is uploaded successfully, add `Groups` to provide access to testers.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-c750982b5208dc4fdaab5cf6179c7c0fe8a6ad41%2Ftestflight_testers_group.png?alt=media\&token=7c34e43c-9d44-4a75-a198-263b54f7f7b0)

2. All the group members will be notified about the new build. Open TestFlight and install the new version.

**Publishing build via Github actions (Automation) to TestFlight**

An Apple developer account must be configured to Inji app to publish builds via TestFlight.

> Testers must be added to group in TestFlight.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-c750982b5208dc4fdaab5cf6179c7c0fe8a6ad41%2Ftestflight_testers_group.png?alt=media\&token=7c34e43c-9d44-4a75-a198-263b54f7f7b0)

1. To deploy the iOS build to testflight, select `Inji iOS build` workflow from github actions.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-b0046ccfddb28e25042ecd948f99777fc8993fe1%2Finji_ios_github_actions.png?alt=media\&token=88e94120-ff7a-4149-b3dd-f9569c8f12d3)

2. Choose the branch, backend URL, theme, testers group from TestFlight to get the build and describe about build details.
3. Click the `Run` workflow button.
4. Once the pipeline has done with building the app (takes around \~25-30min), TestFlight notifies corresponding testers associated with the testers group in email about deployed build details.

![img.png](https://3039626265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaY8BQ4hdzhSchZV814Ev%2Fuploads%2Fgit-blob-e3340e9ef98d09d745eceb9177174fe1c8859e86%2Ftestflight_ios_notification.png?alt=media\&token=6f6e2d03-ef04-420d-b21c-736c868b1c7c)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inji.io/inji-wallet/inji-mobile/build-and-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
