Skip to content

Developer Guide

Custom environment integration

This section explains how to selectively include the full SDK or the noop variant using a gradle property, with a fallback to an environment variable. A gradle property is preferred for local development.

The noop library ensures that no implementation code is included in the final APK. The Literator API interface is retained, however no code is invoked. This makes it simple to integrate the library without worrying about including debug recording functionality in production builds.

Note on custom shells

Android Studio may not read environment variables set via shells such as ZSH in .zshrc. Try adding the new variable under .profile in your $HOME directory. Additionally, ensure the file is sourced.

We recommend leveraging gradle's local.properties file for local development and an environment variable for CI.

Add gradle property

Each Android project typically includes a local.properties file at the root when using Android Studio. Add a variable which can be read in your app's build.gradle file:

literator.include_full_sdk=true

Add environment variable

Optionally, add an environment variable to your shell or CI environment.

export LITERATOR_INCLUDE_FULL_SDK=true

Update app configuration

Include the new variables in your build.gradle or build.gradle.kts file. This dynamically includes either the full SDK or the noop variant. To exclude the SDK, always rely on the noop variant.

When using Kotlin, ensure you import the correct function:

com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

val literatorVersion = "1.9.2"

val localPropsVal = gradleLocalProperties(rootDir).getProperty("literator.include_full_sdk")

val includeFullSdk = localPropsVal ?: System.getenv("LITERATOR_INCLUDE_FULL_SDK")
println("LITERATOR_INCLUDE_FULL_SDK=$includeFullSdk")

if (includeFullSdk == "true") {
    debugImplementation("ai.literal:literator:$literatorVersion")
} else {
    debugImplementation("ai.literal:literator-noop:$literatorVersion")
}

releaseImplementation("ai.literal:literator-noop:$literatorVersion")
def literatorVersion = "1.9.2"

def localProps = new Properties()
localProps.load(project.rootProject.file("local.properties").newDataInputStream())

def includeFullSdk = localProps.getProperty("literator.include_full_sdk") ?: System.getenv("LITERATOR_INCLUDE_FULL_SDK")
println("LITERATOR_INCLUDE_FULL_SDK=$includeFullSdk")

if (includeFullSdk == "true") {
    debugImplementation("ai.literal:literator:$literatorVersion")
} else {
    debugImplementation("ai.literal:literator-noop:$literatorVersion")
}

releaseImplementation("ai.literal:literator-noop:$literatorVersion")

Ensure a gradle sync is performed after changing any gradle or .properties file.

Accessing results

Logcat

Logcat prints a message once a session is enqueued for processing. Extract the URL with a filter on the Literator tag.

# With regular adb
adb logcat com.myapp.name -s Literator

# With pidcat (popular Logcat tool)
pidcat com.myapp.name -t Literator

You should see something like the following with your board URL:

Literator start

Session callback

Apply a callback to be notified of a successful session start. This callback also contains the URL where screens will appear once a recording has been uploaded and processed.

Literator.setSessionCallback(object: LiteratorSessionCallback {
    override fun onSessionStarted(url: String) {
        Log.v("My app tag", "After uploading, session will be available here: $url")
    }
})
Literator.setSessionCallback(new LiteratorSessionCallback() {
    @Override
    public void onSessionStarted(@NotNull String url) {
        Log.v("My app tag", "After uploading, session will be available here: " + url);
    }
});

Avoid leaks

Remember to remove the callback using removeSessionCallback if using lifecycle dependant classes such as activities or fragments.