Build & Deployment

Repositories

Prerequisite

Android - Build and Run

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 8.0.2

sdk install java 11.0.18-amzn

Step 4:

Configure Expo, refer here.

Step 5:

Configure Android SDK, refer here.

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

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.

  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 8.5
  • To check the installed gradle version.

gradle -V

Step 4:

  • Install Java JDK, refer here.

[!TIP]
Restart system

Step 5:

  • Install expo

npm install --global expo-cli

Step 6:

  • Install Android SDK, refer here.

Step 7:

  • Install Node, refer here.

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

Prerequisites for running on device

  1. Requires Bluetooth v4.2 and above

  2. Android v23 and above for Android

Command to build

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: orange and purple.

  • The default theme of the app is orange.

  • To change the theme of the application, go to .env file and change the value of APPLICATION_THEME to orange or purple

Step 4:

  • Go to the root folder of the project in the terminal.

  • Install all the dependencies using npm install.

Step 5:

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.

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 this 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

Setting Up Google API Services and Client ID

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

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

Then enable the API.

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

Click on CREATE CREDENTIALS and choose OAuth client ID

Choose Appliation type as Android

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>"

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.

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

  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.

  1. 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.

  1. 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.

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

  1. Choose the branch, backend url, theme and describe about build details.

  2. Click the Run workflow button.

  3. 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.

  4. 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

Installation and Keystore generation

Step 1:

Follow the Steps to configure Node & npm, Expo and generate debug keystore

Step 2:

Configure XCode, refer here.

Step 3:

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

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

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.

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.

Upload in TestFlight

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

  1. 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.

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

  1. Choose the branch, backend URL, theme, testers group from TestFlight to get the build and describe about build details.

  2. Click the Run workflow button.

  3. 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.

Last updated

Copyright © 2021 MOSIP. This work is licensed under a Creative Commons Attribution (CC-BY-4.0) International License unless otherwise noted.