Unified SDK for Android reference
This reference documents every public class of com.amplitude:unified-android and every option on UnifiedConfigurationBuilder, verified against version 1.1.0. That version bundles Android-Kotlin SDK 1.36.0 (com.amplitude:analytics-android), Session Replay Android plugin 0.31.0, and Experiment Android SDK 1.18.0. Every analytics method behaves as the Android-Kotlin SDK reference describes. For changes between versions, go to the Unified SDK changelog.
import com.amplitude.unified.AmplitudeUnified
import com.amplitude.unified.UnifiedConfigurationBuilder
Exports
| Class | Description |
|---|---|
AmplitudeUnified | The client. Extends com.amplitude.android.Amplitude, so it has every Android-Kotlin SDK method. |
UnifiedConfigurationBuilder | Holds the analytics, Session Replay, and Experiment options. |
SessionReplayConfigurationBuilder | Session Replay options. |
ExperimentConfigurationBuilder | Experiment options. |
BuildConfig | Android build constants. BuildConfig.UNIFIED_VERSION holds the Unified SDK version that the SDK writes into each event's library. |
Every analytics method, such as track(), identify(), setUserId(), reset(), flush(), and add(), comes from the Android-Kotlin SDK. Go to the Android-Kotlin SDK reference.
AmplitudeUnified
open class AmplitudeUnified : com.amplitude.android.Amplitude
Constructors
AmplitudeUnified(
apiKey: String,
applicationContext: Context,
configure: UnifiedConfigurationBuilder.() -> Unit = {},
)
AmplitudeUnified(configurationBuilder: UnifiedConfigurationBuilder)
| Parameter | Type | Description |
|---|---|---|
apiKey | String | Your Amplitude project API key. |
applicationContext | Context | An Android context. The SDK uses context.applicationContext when it isn't null. |
configure | UnifiedConfigurationBuilder.() -> Unit | Optional. Sets options on a new UnifiedConfigurationBuilder. |
configurationBuilder | UnifiedConfigurationBuilder | A builder you configured. Same result as UnifiedConfigurationBuilder.build(). |
The first constructor has @JvmOverloads, so Java can call new AmplitudeUnified(apiKey, context) without the lambda.
The constructor builds Analytics, then installs Session Replay, then Experiment, each as a plugin. If a product throws during setup, the SDK logs Failed to install plugin "<name>": <exception>, skips that product, and keeps the rest running. Analytics finishes loading stored identity in the background. Wait for isBuilt before reading identity that must come from storage:
amplitude.isBuilt.await() // inside a coroutine
val deviceId = amplitude.getDeviceId()
analytics
val analytics: AmplitudeUnified
Returns the same instance. Use it when you want call sites to read amplitude.analytics.track(...).
sessionReplay
val sessionReplay: SessionReplay?
Returns the Session Replay client (com.amplitude.android.sessionreplay.SessionReplay), or null when Session Replay is turned off or failed to install. Call start() to start or resume capture and stop() to pause it. For other members, go to the Session Replay Android plugin.
experiment
val experiment: ExperimentClient?
Returns the Experiment client (com.amplitude.experiment.ExperimentClient), or null when Experiment is turned off, failed to install, or the instance holds more than one Experiment plugin. For client methods such as variant(), fetch(), and all(), go to the Experiment Android SDK.
UnifiedConfigurationBuilder
open class UnifiedConfigurationBuilder(apiKey: String, applicationContext: Context)
| Member | Description |
|---|---|
analytics: ConfigurationBuilder | The Android-Kotlin SDK's com.amplitude.android.ConfigurationBuilder. It accepts every Android-Kotlin SDK configuration option. Java: getAnalytics(). |
sessionReplay: SessionReplayConfigurationBuilder | Go to SessionReplayConfigurationBuilder. Java: getSessionReplay(). |
experiment: ExperimentConfigurationBuilder | Go to ExperimentConfigurationBuilder. Java: getExperiment(). |
analytics(configure), sessionReplay(configure), experiment(configure) | Apply a lambda to the matching builder and return this builder, so calls chain. |
build(): AmplitudeUnified | Creates the client. |
The SDK copies the options when it builds the client. Changing a builder afterward has no effect on that client.
UnifiedConfigurationBuilder builder =
new UnifiedConfigurationBuilder("YOUR_API_KEY", getApplicationContext());
builder.getAnalytics().setFlushQueueSize(20);
builder.getExperiment().setDeploymentKey("YOUR_DEPLOYMENT_KEY");
AmplitudeUnified amplitude = builder.build();
SessionReplayConfigurationBuilder
| Option | Type | Default | Description |
|---|---|---|---|
enabled | Boolean | true | When false, the SDK doesn't install Session Replay, and sessionReplay returns null. |
sampleRate | Number | 0.0 | Fraction of sessions to record, from 0.0 to 1.0. The default records nothing. |
enableRemoteConfig | Boolean | true | Turns on Session Replay remote configuration from Amplitude. |
serverUrl | String? | null | A proxy URL for Session Replay uploads. |
bandwidthLimitBytes | Int? | null | Daily upload limit on metered networks, in bytes. null keeps the Session Replay default. |
storageLimitMB | Int? | null | Local storage limit for recordings, in megabytes. null keeps the Session Replay default. |
privacyConfig | PrivacyConfig | PrivacyConfig() | Masking rules. Go to the Session Replay Android plugin. |
autoStart | Boolean | true | Starts capture when the plugin finishes setup. Set false and call sessionReplay?.start() to choose when capture starts. |
recordLogOptions | RecordLogOptions | RecordLogOptions() | Options for recording app logs into replays. |
captureWebViews | Boolean | false | Records eligible WebView content. |
Session Replay takes the API key, server zone, device ID, and session ID from Analytics. It has no user ID of its own.
ExperimentConfigurationBuilder
| Option | Type | Default | Description |
|---|---|---|---|
enabled | Boolean | true | When false, the SDK doesn't install Experiment, and experiment returns null. |
deploymentKey | String? | null | The Experiment deployment key. When null, Experiment uses the Analytics API key. |
config | ExperimentConfig | ExperimentConfig() | Every Experiment Android SDK option. The SDK replaces instanceName, serverZone, the user provider, and the exposure tracking provider with values from Analytics. |
Was this helpful?
For AI agents: a documentation index is available at /docs/llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.