Skip to main content
Since version 1.0.4 and onwards, our SDK is securely storing the session key on the device’s local storage. Previously, that was done directly in the webview’s localStorage, which isn’t very secure. On iOS devices, the session is securely stored inside the Keychain and retrieved only when necessary. On all other devices, the session is stored inside AES-encrypted PlayerPrefs, so it’s still secure. However, if you want to maximize the security of your users’ session keys in the actual Android Keystore, you would need to do the following: Since our implementation of Android Secure Storage depends on the AndroidX crypto library, we need to manually add it to the Unity project. To do so: Go to Player Settings -> Other Settings: Set Custom Main Gradle Template and Custom Gradle Settings Template checkboxes to true if they’re not already set. Inside the mainTemplate.gradle, add the following inside the dependencies block: implementation("androidx.security:security-crypto:1.1.0") If you don’t have any other custom library of your own, it should look like this
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation("androidx.security:security-crypto:1.1.0")
**DEPS**}
Since Unity is using an old Kotlin version, there might be a clash between Unity’s Kotlin version and the androidx crypto Kotlin version. To resolve this, add the following lines at the very bottom of the main template file, below the **EXTERNAL_SOURCES**
configurations.all {
    resolutionStrategy {
        // Adjust the version number '1.8.22' if your project uses a newer Kotlin version.
        force 'org.jetbrains.kotlin:kotlin-stdlib:1.8.22'
        
        // Exclude the older modules that contain the duplicate classes (jdk7 and jdk8 specific ones)
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
        exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
    }
}
When it comes to settingsTemplate.gradle, you should leave it as-is. It adds the Google repository inside the pluginManagement block, so that’s all that is needed there. If you didn’t successfully installed the AndroidX Crypto library you will see the following error in the Android Logcat
User does not have the androidX crypto library
Followed by the stacktrace and a message that the class hasn’t been found.
I