Merge pull request #55 from idpass/38-Dev-workflow-apk-build-support-env-var-signing-keystore

Dev workflow APK build support env var for signing keystore.
This commit is contained in:
Ken Lewerentz
2022-03-01 20:28:56 +07:00
committed by GitHub
2 changed files with 48 additions and 19 deletions

View File

@@ -8,10 +8,27 @@ Be sure to have the following build tools installed before proceeding:
- [Gradle](https://gradle.org/install/)
- [Java 8](https://www.oracle.com/ph/java/technologies/javase/javase8-archive-downloads.html)
- [Expo](https://docs.expo.dev/get-started/installation/)
- [Android SDK](https://developer.android.com/)
## Generate keystore for APK signing
```shell
keytool \
-genkey -v \
-storetype PKCS12 \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-storepass 'android' \
-keypass 'android' \
-alias androidreleasekey \
-keystore android/app/release.keystore \
-dname "CN=io.mosip.residentapp,OU=,O=,L=,S=,C=US"
```
## Running the app
```bash
```shell
# Install all dependencies
npm install
# run dev client
@@ -31,20 +48,27 @@ The app is available in this repository's `frontend/android` directory. Open thi
More info here: [Build your app using Android Studio](https://developer.android.com/studio/run)
## Build via command line
You need Android SDK CLI to build APK.
1. Build for Mosip Philippines test
```bash
```shell
# 1. Install dependencies
npm install
# Setup the environment variable for keystore
export RELEASE_KEYSTORE=release.keystore
export RELEASE_KEYSTORE_ALIAS=androidreleasekey
export RELEASE_KEYSTORE_PASSWORD=android
# Use DEBUG_KEYSTORE, DEBUG_KEYSTORE_ALIAS, DEBUG_KEYSTORE_PASSWORD for debug build
# Use one of following command to build the flavor you need.
# Build for Mosip Philippines test
npm run build:android:ph
```
2. Build for Newlogic test
```bash
# Build for Newlogic test
npm run build:android:newlogic
```
Note for release builds you will need to have a keystore: [Create a Keystore](https://medium.com/@tom.truyen/create-an-android-keystore-using-keytool-commandline-10399a62e774)
More info here: [Build your app from the command line](https://developer.android.com/studio/build/building-cmdline)
## Credits

View File

@@ -170,18 +170,23 @@ android {
}
signingConfigs {
release {
// TODO add proper release keystore via local.properties
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
def keystore = System.getenv("RELEASE_KEYSTORE") ?: "debug.keystore"
def keystoreAlias = System.getenv("RELEASE_KEYSTORE_ALIAS") ?: "androiddebugkey"
def keystorePass = System.getenv("RELEASE_KEYSTORE_PASSWORD") ?: "android"
storeFile file("$keystore")
storePassword "$keystorePass"
keyAlias "$keystoreAlias"
keyPassword "$keystorePass"
v2SigningEnabled true
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
def keystore = System.getenv("DEBUG_KEYSTORE") ?: "debug.keystore"
def keystoreAlias = System.getenv("DEBUG_KEYSTORE_ALIAS") ?: "androiddebugkey"
def keystorePass = System.getenv("DEBUG_KEYSTORE_PASSWORD") ?: "android"
storeFile file("$keystore")
storePassword "$keystorePass"
keyAlias "$keystoreAlias"
keyPassword "$keystorePass"
v2SigningEnabled true
}
}
@@ -192,7 +197,7 @@ android {
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}