adjust-icon

Android Web bridge v5 migration guide

Before you begin

Here’s what you need to do before updating to SDK v5:

  1. SDK v5 supports SDK signature verification natively. If you currently use the SDK signature library, you need to uninstall this first.
  2. If your app targets API versions lower than 21 you need to update your app before you can use SDK v5.

Install the SDK

To start using SDK v5, you need to add it as a dependency in your project. To do this:

  1. Remove any older versions of the SDK you currently have in your build.gradle file.

  2. Add the following dependencies to your build.gradle file:

    build.gradle
    dependencies {
    implementation 'com.adjust.sdk:adjust-android:5.0.0'
    implementation 'com.android.installreferrer:installreferrer:2.2'
    // Add the following if you are using the Adjust SDK inside web views on your app
    implementation 'com.adjust.sdk:adjust-android-webbridge:5.0.0'
    }

Update the initialization method

Changed in v5

In SDK v4, the initialization method is Adjust.onCreate(AdjustConfig). This has been changed to Adjust.initSdk(AdjustConfig) in SDK v5.

const adjustConfig = new AdjustConfig(this, appToken, environment);
Adjust.onCreate(adjustConfig); // v4
Adjust.initSdk(adjustConfig); // v5

Changed APIs

Changed in v5

The following APIs have changed in SDK v5.

Disable and enable the SDK

In SDK v4, you can enable and disable the SDK by calling Adjust.setEnabled() with a boolean value.

  • Call Adjust.setEnabled(false) to disable the SDK.
  • Call Adjust.setEnabled(true) to enable the SDK
Adjust.setEnabled(false); // disable SDK
Adjust.setEnabled(true); // enable SDK

In SDK v5, this feature is split into separate commands for clarity.

  • Call Adjust.disable() to disable the SDK.
  • Call Adjust.enable() to enable the SDK.
Adjust.disable(); // disable SDK
Adjust.enable(); // enable SDK

Offline mode

In SDK v4, you can enable and disable offline mode in the SDK by calling Adjust.setOfflineMode() with a boolean value.

Adjust.setOfflineMode(false); // put SDK in offline mode
Adjust.setOfflineMode(true); // put SDK back in online mode

In SDK v5, this feature is split into separate commands for clarity.

  • Call Adjust.switchToOfflineMode() to set the SDK to offline mode.
  • Call Adjust.switchBackToOnlineMode() to set the SDK back to online mode.
Adjust.switchToOfflineMode(); // put SDK in offline mode
Adjust.switchBackToOnlineMode(); // put SDK back in online mode

Preinstall recording

In SDK v4, you can enable the Adjust SDK to send install data to Adjust when your app comes preinstalled on a device by calling the setPreinstallTrackingEnabled method of your AdjustConfig instance with a boolean argument.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setPreinstallTrackingEnabled(true);

In SDK v5, this method has been renamed to enabledPreinstallTracking for clarity. This new method takes no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enablePreinstallTracking();

Enable cost data in attribution

In SDK v4, you can enable the SDK to send cost data as part of a user’s attribution by calling the setNeedsCost method of your AdjustConfig instance with a boolean argument.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setNeedsCost(true);

In SDK v5, this method has been renamed to enableCostDataInAttribution for clarity. This new method takes no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enableCostDataInAttribution();

Send information in background

In SDK v4, you can enable the SDK to send information to Adjust when the app is running in the background by calling the setSendInBackground method of your AdjustConfig instance with a boolean argument.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setSendInBackground(true);

In SDK v5, this method has been renamed to enableSendingInBackground. This new method takes no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enableSendingInBackground();

Read device IDs only once

In SDK v4, you can configure the SDK to only read device IDs once upon initialization by calling the setReadDeviceInfoOnceEnabled method of your AdjustConfig instance with a boolean value.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setReadDeviceInfoOnceEnabled(true);

In SDK v5, this method has been renamed to enableDeviceIdsReadingOnce for clarity. This new method takes no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enableDeviceIdsReadingOnce();

Session callback parameters

Session callback parameters has been renamed to Global callback parameters in SDK v5.

Adjust.addSessionCallbackParameter("foo", "bar");
Adjust.removeSessionCallbackParameter("foo");
Adjust.resetSessionCallbackParameters();
Adjust.addGlobalCallbackParameter("foo", "bar");
Adjust.removeGlobalCallbackParameter("foo");
Adjust.removeGlobalCallbackParameters();

Session partner parameters

Session partner parameters has been renamed to Global partner parameters in SDK v5.

Adjust.addSessionPartnerParameter("foo", "bar");
Adjust.removeSessionPartnerParameter("foo");
Adjust.resetSessionPartnerParameters();
Adjust.addGlobalPartnerParameter("foo", "bar");
Adjust.removeGlobalPartnerParameter("foo");
Adjust.removeGlobalPartnerParameters();

Event deduplication

In SDK v4, event deduplication is coupled with the event order ID and is limited to a maximum of 10 unique IDs.

const event = new AdjustEvent("event_token");
event.setOrderId("deduplication_id");
Adjust.trackEvent(event);

In SDK v5, the feature is decoupled from order ID. A new ID field called deduplicationId has been added for event deduplication. Users can set a custom limit on the number of deduplicationId that can be added to the list for identifying duplicate events. By default, the limit is set to 10.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setEventDeduplicationIdsMaxSize(20); // if not set, then 10
Adjust.initSdk(adjustConfig);
const event = new AdjustEvent("event_token");
event.setDeduplicationId("deduplication_id");
Adjust.trackEvent(event);

COPPA compliance

In SDK v4, COPPA compliance is set by calling the setCoppaCompliantEnabled method on your config object with a boolean argument.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setCoppaCompliantEnabled(true);

In SDK v5, this method is renamed to enableCoppaCompliance for clarity. This new method accepts no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enableCoppaCompliance();

Play Store Kids Apps

In SDK v4, you can mark an app as a Play Store Kids app by calling the setPlayStoreKidsAppEnabled method on your config object with a boolean argument.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setPlayStoreKidsAppEnabled(true);

In SDK v5, this method is renamed to enablePlayStoreKidsCompliance for clarity. This new method accepts no arguments.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.enablePlayStoreKidsCompliance();

Set data residency and URL strategy

In SDK v4, URL strategy and data residency domains are defined as constants in the AdjustConfig class.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(AdjustConfig.DataResidencyEU);

In SDK v5, you need to pass your chosen domain or domains as an array. You can also set the following:

  • useSubdomains (boolean): Whether the source should prefix a subdomain.
  • isDataResidency (boolean): Whether the domain should be used for data residency.
const adjustConfig = new AdjustConfig(this, appToken, environment);
const domains = ["domain1", "domain2"];
const useSubdomains = true;
const isDataResidency = false;
adjustConfig.setUrlStrategy(domains, useSubdomains, isDataResidency);

Check the table below to see how to configure your URL strategy in SDK v5.

v4v5 - main and fallback domainv5 - use sub domainsv5 - is Data Residency
AdjustConfig.DataResidencyEU"eu.adjust.com"truetrue
AdjustConfig.DataResidencyTR"tr.adjust.com"truetrue
AdjustConfig.DataResidencyUS"us.adjust.com"truetrue
AdjustConfig.UrlStrategyChina"adjust.world", "adjust.com"truefalse
AdjustConfig.UrlStrategyCn"adjust.cn", "adjust.com"truefalse
AdjustConfig.UrlStrategyCnOnly"adjust.cn"truefalse
AdjustConfig.UrlStrategyIndia"adjust.net.in", "adjust.com"truefalse

Examples

India URL strategy
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["adjust.net.in", "adjust.com"], true, false);
China URL strategy
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["adjust.world", "adjust.com"], true, false);
China only URL strategy
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["adjust.cn"], true, false);
EU data residency
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["eu.adjust.com"], true, true);
Turkey data residency
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["tr.adjust.com"], true, true);
US data residency
const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUrlStrategy(["us.adjust.com"], true, true);

Disable third party sharing globally

In SDK v4, you can call the Adjust.disableThirdPartySharing() method to globally disable sharing information with third parties globally.

Adjust.disableThirdPartySharing();

This feature has been removed from SDK v5. In SDK v5, use the Adjust.trackThirdPartySharing() method to enable or disable third party sharing.

const adjustThirdPartySharing = new AdjustThirdPartySharing(true);
Adjust.trackThirdPartySharing(adjustThirdPartySharing);

Device ID getters

In SDK v4, all device ID getter methods run synchronously. In SDK v5, these methods have been changed to run asynchronously.

ADID getter
Adjust.getAdid(function (adid) {
alert("Ad Id:\n" + adid);
});
Attribution information getter
Adjust.getAttribution(function (attribution) {
alert(
"Tracker token = " +
attribution.trackerToken +
"\n" +
"Tracker name = " +
attribution.trackerName +
"\n" +
"Network = " +
attribution.network +
"\n" +
"Campaign = " +
attribution.campaign +
"\n" +
"Adgroup = " +
attribution.adgroup +
"\n" +
"Creative = " +
attribution.creative +
"\n" +
"Click label = " +
attribution.clickLabel,
);
});
SDK version getter
Adjust.getSdkVersion(function (sdkVersion) {
alert("SDK version:\n" + sdkVersion);
});
Enabled status getter
Adjust.isEnabled(function (isEnabled) {
alert("Is SDK enabled? " + isEnabled);
});

Removed APIs

Removed in v5

The following APIs have been removed in SDK v5.

Event buffering

SDK v4 supports event buffering. This feature stores requests event, ad revenue, push tokens, and other information on a local buffer to send at a later date.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setEventBufferingEnabled(true);

This setting has been removed in SDK v5.

Custom user agent string

SDK v4 supports setting a custom User Agent by calling the setUserAgent method of your AdjustConfig instance with a user agent string.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setUserAgent("user_agent_value");

This setting has been removed in SDK v5.

Set whether a device is known

In SDK v4, you can call the setDeviceKnown method of your AdjustConfig instance to manually inform the SDK whether a device is known.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setDeviceKnown(true);

This setting has been removed in SDK v5.

Delay SDK start

SDK v4 supports delaying the start of the SDK by calling the setDelayStart method on your AdjustConfig instance with up to 120 seconds of delay. If the app is ready before the delay ends, information can be sent immediately by calling Adjust.sendFirstPackages.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setDelayStart(delay);
Adjust.sendFirstPackages();

Both of these methods have been removed in SDK v5.

In SDK v4, you can pass a deep link URL to Adjust in the Web bridge by calling the Adjust.appWillOpenUrl() method.

Adjust.appWillOpenUrl(data, getApplicationContext());

This method has been removed in SDK v5.

Send ad revenue from a specific source

In SDK v4, you can send ad revenue from a specific source by passing a source and payload to the Adjust.trackAdRevenue() method.

Adjust.trackAdRevenue(source, payload);

This method has been removed in SDK v5.

Set an App Secret

SDK v4 supports setting an App Secret by calling the setAppSecret method of your AdjustConfig instance to sign the SDK traffic with.

const adjustConfig = new AdjustConfig(this, appToken, environment);
adjustConfig.setAppSecret(secretId, info1, info2, info3, info4);

This setting has been removed in SDK v5.