Note: At this point, you should already have completed Base app configuration section.
In order to configure the building of your application for an Android platform, you can either rely on automatic command which will everything for you, or follow to manual steps.
Note: Automatic configuration works only for Unix like OS.
-
Add the following command to your
scripts
section of your apppackage.json
:- Linux, Windows:
"scripts": { ... "evernym-sdk:configure-android": "./node_modules/@evernym/react-native-white-label-app/files/android/configure-android.sh" },
- MacOs
"scripts": { ... "evernym-sdk:configure-android": "./node_modules/@evernym/react-native-white-label-app/files/android/configure-android-mac.sh" },
- Linux, Windows:
-
Run the following command in your project directory:
yarn evernym-sdk:configure-android
-
To build app with SDK, you need to increase the available jvm memory in
android/gradle.properties
org.gradle.jvmargs=-Xmx4608m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
Add blacklist to your
android/gradle.properties
android.jetifier.blacklist=bcprov
-
Set distribution url in your
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl='https\://services.gradle.org/distributions/gradle-6.9-bin.zip
-
Set the minimum supported SDK version in your
android/build.gradle
:buildscript { ext { ... minSdkVersion = 23 ... } ...
-
Add the libvcx android repositories in your
android/build.gradle
:allprojects { repositories { ... maven { url 'https://evernym.mycloudrepo.io/public/repositories/libvcx-android' } maven { url 'https://evernym.mycloudrepo.io/public/repositories/evernym' } } }
-
Set gradle version and add kotlin dependence in your
android/build.gradle
:dependencies { classpath 'com.android.tools.build:gradle:4.2.1' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20' ... }
-
Setup packaging options in your
android/app/build.gradle
:android { ... packagingOptions{ pickFirst 'lib/armeabi-v7a/libc++_shared.so' pickFirst 'lib/arm64-v8a/libc++_shared.so' pickFirst 'lib/x86_64/libc++_shared.so' pickFirst 'lib/x86/libc++_shared.so' if (enableHermes) { exclude '**/libjsc*.so' } } ... }
-
Add fonts in your
android/app/build.gradle
:apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
-
Set default configuration for the camera in your
android/app/build.gradle
:android { ... defaultConfig { ... missingDimensionStrategy 'react-native-camera', 'general' } ... }
-
Add kotlin dependence in your
android/app/build.gradle
:dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib:1.4.20" ... }
-
Replace your
android/app/src/main/AndroidManifest.xml
with AndroidManifest.xml and change placeholders (react-native-white-label-app-placeholder
) in copiedAndroidManifest.xml
:
package
- your original android package name
-
Create
android/app/src/main/res/xml/
folder and copy file_viewer_provider_paths.xml file there. -
Update your
MainActivity
by adding the following code (it's needed to configure your app storage):import android.content.ContextWrapper; import android.system.Os;
@Override protected void onStart() { super.onStart(); try { ContextWrapper c = new ContextWrapper(this); Os.setenv("EXTERNAL_STORAGE", c.getFilesDir().toString(), true); } catch (Exception e) { e.printStackTrace(); } }
There are two strategies regarding receiving messages by an application which described here:
If you wish to use Push Notifications strategy you need to set variable USE_PUSH_NOTIFICATION=true
and follow steps bellow to configure Google Firebase for Android:
Official documentation: https://developer.android.com/guide/topics/ui/notifiers/notifications
-
Put
google-services.json
file into yourandroid/app
folder. Example file can be found (showing structure) here. Note that push notifications will not work if you use this file, to get working notifications you need to provide your own account information. -
Add
google-services
dependencies into yourandroid/build.gradle
file.dependencies { ... classpath 'com.google.gms:google-services:4.2.0' }
-
Add
google-services
plugin into yourandroid/app/build.gradle
file.apply plugin: 'com.google.gms.google-services'
-
Uncomment the text located under
Firebase configuration
inAndroidManifest.xml
:
-
Uncomment the text located under
Deep Linking configuration
inAndroidManifest.xml
: -
Set Branch keys in your
android/app/build.gradle
file:manifestPlaceholders = [BRANCH_LIVE_KEY: "key_live_....", BRANCH_TEST_KEY:"key_test_..."]
-
Change placeholders (
react-native-white-label-app-placeholder
) forBranch URI Scheme
andBranch App Links
inAndroidManifest.xml
: -
Added branch import into your
MainApplication.java
:// branch needs to have a referral in initializing import io.branch.referral.Branch;
Solution: Add patch into your project for the following package:
react-native-screens
- link
Solution: Add patches into your project for the following packages: