Gradle Requirements
When building for Android, the voice service requires some configuration in the gradle files of your application. Unity provides a gradle template option to help with this. If you are already using a gradle template for another plugin, you will need to append the required changes to this. Otherwise you are able to use the provided examples.
- Open the Unity Project Settings: Edit > Project Settings…
- Select the Player section and switch to the Android build target
- Scroll down to and expand Publishing Settings
- Under the Build header, enable the ‘Custom Main Gradle Template’ and ‘Custom Gradle Properties Template’ options. The following files will be added to your project:
Assets\Plugins\Android\mainTemplate.gradle
Assets\Plugins\Android\gradleTemplate.properties
- Open the mainTemplate.gradle file (any text editor is fine)
- In the
dependencies
section towards the top, add the following line:
implementation 'com.opentok.android:opentok-android-sdk:2.22.2'
- Save & close
- Open the gradleTemplate.properties file (any text editor is fine)
- Add the following line before the
**ADDITIONAL PROPERTIES**
line
android.useAndroidX=true
An example of modified mainTemplate.gradle and gradleTemplate.properties files. These are the default Unity 2020.3 templates modified only with the requirements for Immerse SDK voice.
apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// Required for Immerse SDK voice
implementation 'com.opentok.android:opentok-android-sdk:2.22.2'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**
}**REPOSITORIES**
**IL_CPP_BUILD_SETUP**
**SOURCE_BUILD_SETUP**
**EXTERNAL_SOURCES**
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=**MINIFY_WITH_R_EIGHT**
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
// Required for Immerse SDK voice
android.useAndroidX=true
**ADDITIONAL_PROPERTIES**