Learn about the breaking changes introduced in the Android (Kotlin) SDK.
6 minute read
This guide walks you through the breaking changes introduced in the Android (Kotlin) SDK.
Overview
The Android (Kotlin) SDK is built from scratch while retaining the core functionalities of the legacy Android (Java) SDKAndroid (Java) refers to the legacy RudderStack Android SDK. Note that it will be deprecated soon.
For new implementations, use the Android (Kotlin) SDK instead.
.
Note the following before upgrading your SDK:
This SDK does not support automatic data migration from the legacy Android (Java) SDK.
Any data persisted by the Android (Java) SDK is not carried over automatically.
SDK initialization
The way of initializing the Android (Kotlin) SDK has changed. See the following snippets for comparison:
The following fields are updated in the Android (Kotlin) SDK:
Android (Java) — Legacy
Android (Kotlin)
RudderTraits
Traits
RudderProperty
Properties
RudderMessageBuilder and RudderMessage are no longer used in the Android (Kotlin) SDK.
RudderOption changes
The way for creating a RudderOption instance has changed in the Android (Kotlin) SDK:
In this SDK, a RudderOption instance was created using method chaining:
valoption=RudderOption().putIntegration(CustomFactory.FACTORY,false).putIntegration("Amplitude",false).putExternalId("brazeExternalId","<id>")valtraits=RudderTraits().put("key","value")// Identify event is used just for demonstration purposes.
rudderClient.identify("user 1",traits,option)
In Android (Kotlin) SDK, RudderOption is instantiated using the constructor arguments instead of method chaining:
valoption=RudderOption(customContext=buildJsonObject{put("key","value")},integrations=buildJsonObject{put("Amplitude",true)put("INTERCOM",buildJsonObject{put("lookup","phone")})},externalIds=listOf(ExternalId(type="brazeExternalId",id="<id>"),))valtraits=buildJsonObject{put("key-1","value-1")}// Identify event is used just for demonstration purposes.
RudderAnalyticsUtils.analytics.identify(userId="User1",traits=traits,options=option)
Accepted two arguments - type (String) and enabled (Boolean).
Converted into constructor arguments and renamed to integrations of a single JsonObject type.
putCustomContext
Accepted two arguments - type (String) and context (Map).
Converted into constructor arguments and renamed to customContext of a single JsonObject type.
putExternalId
Accepted two arguments - type (String) and id (String).
Converted into constructor arguments and renamed to externalIds of type List<ExternalId>, where <ExternalId> is a data class with a type (String) and id (String).
SDK configuration changes
The following table maps the SDK configuration options available in the Android (Java) SDKAndroid (Java) refers to the legacy RudderStack Android SDK. Note that it will be deprecated soon.
For new implementations, use the Android (Kotlin) SDK instead.
to the new Android (Kotlin) SDK:
To preserve the anonymousId value on a reset API call or meet a custom requirement, you can use a custom plugin to manage anonymousId for each event. Custom plugins let you modify the event payload as needed.
Flush configuration
Android (Java) — Legacy
Android (Kotlin)
The following configuration options are available:
You can pass custom context during the SDK initialization.
Support for this feature is removed. Use a custom plugin to set custom context for all events including automatically-tracked events (for example, lifecycle events).
Use a custom plugin to enable or disable event delivery for specific destinations across all event calls, including automatically tracked events (like lifecycle events) using the SDK.
Session tracking is tightly coupled with automatic tracking of lifecycle events. That means you cannot use session tracking if automatic lifecycle tracking is disabled.
Session tracking is decoupled with automatic tracking of lifecycle events. That means you can use the session tracking and automatic lifecycle event tracking mechanisms independently.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.