Capture Custom Fonts

Android instructions to capture custom font files for display in session replay. Includes React Native on Android.

If you use custom fonts, and notice missing icons or incorrectly sized text in Session Replay, you may want to follow these instructions to upload your fonts on release builds. This will enable custom fonts to display in Session Replay. Custom font replay requires a minimum SDK version of 1.33.8.

Install plugin

Include the following in your gradle build file

buildscript {
    repositories {
        // Existing repositories
        maven {
            url = uri("https://storage.googleapis.com/logrocket-maven/")
        }
    }
    dependencies {
        // Existing dependencies
        classpath("com.logrocket.gradle:android:0.2.0")
    }
}
buildscript {
  repositories {
    // Existing repositories
    maven { url "https://storage.googleapis.com/logrocket-maven/" }
  }
  dependencies {
    // Existing dependencies
    classpath "com.logrocket.gradle:android:0.2.0"
  }
}

Apply the Plugin

Adding the dependency is not enough to activate the plugin. The following must also be added to your application's gradle build file

plugins {
    id("com.android.application") // Should already exist, our plugin must be added after this plugin.
    id("com.logrocket.gradle.android")
}
apply plugin: 'com.android.application' // Should already exist, must add our plugin after this.
apply plugin: 'com.logrocket.gradle.android'

Authorization

Include your API key (found in General Settings > Development > API key) in one of two approaches: through an environment variable or directly in your application's gradle file.

as an environment variable

The API key can be set as an environment variable, such as through your CI system, so you do not need to commit the key to your repository.

LOGROCKET_API_KEY=<org:app:key>

in your application's gradle build file

logrocket {
    apiKey = "<org:app:key>"
}
logrocket {
    apiKey = "<org:app:key>"
}

Additional Configuration

By default, the android plugin is only applied for production builds. If you would like to test it on another build variant you may specify a list of variants in your application's gradle build file.

logrocket {
    enabledVariants = setOf("debug", "release")
}
logrocket {
    enabledVariants = ["debug", "release"].toSet()
}

Font resource location

Font Resources are captured if the font exists in app/src/main/res/fonts (or a sub-folder).

For React Native we will capture fonts that have been installed into the Android application at android/app/src/main/assets/fonts.