Skip to main content

EcommAndroid

Integrate using the Android SDKDirect link to Integrate using the Android SDK

Rokt partners can use the Android SDK to display overlay or embedded placements, while Rokt brands can use it to record conversions for their campaigns. The Rokt Android SDK is deployed using Maven and Gradle.

note

The Rokt Android SDK contains ProGuard rules and does not require additional configuration.

All use cases of the SDK follow the same initial steps to integrate and initialize the SDK. At a high level, these steps are:

  1. Set up a workspace and enable the Rokt Gradle repository
  2. Add the Rokt Placement plugin
  3. Add the Rokt Android SDK module
  4. Initialize the Rokt Android SDK

Following these steps, the execute method of the SDK can then be used in various ways to suit the required use case.

note

This guide assumes that you are familiar with Gradle and know how to install a plugin for Android development.

Set up the Android SDKDirect link to Set up the Android SDK

  1. Set up a workspace and enable the Rokt Gradle repository.
  2. Add the Rokt Widget plugin repository URL in the build.gradle file for the project.
 // file => build.gradle (Project: ....)

allprojects {
repositories {
google()
mavenCentral()
maven {
url "https://rokt-eng-us-west-2-mobile-sdk-artefacts.s3.amazonaws.com"
}
}
}

Or if you are using Gradle 7.0.0 and above, where the repository settings that were previously in the top-level build.gradle file are now in the settings.gradle file, add the following in settings.gradle file.

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url "https://rokt-eng-us-west-2-mobile-sdk-artefacts.s3.amazonaws.com"
}
}
}
  1. Add the Rokt Android SDK module to build.gradle for the module.
 // file => build.gradle (Module: ...)

dependencies {
...
// Note: 3.11.0 reflects the latest version of the Rokt Android SDK.
implementation 'com.rokt:roktsdk:3.11.0'
...
}
  1. Initialize the Rokt SDK prior to using it in any activity. We recommend calling the init method from the LauncherActivity class.
caution

Contact Rokt to get the Rokt Account ID associated with your account. To test your integration, you can use the Rokt Account ID below, but you need to replace it with your unique Rokt Account ID before launching in production.

Test account ID: 222

import com.rokt.roktsdk.Rokt;

public class LauncherActivity extends Activity {
override fun onCreate(savedInstanceState: Bundle"?") {
...
// The following will reveal a demo integration. To view your integration:
// 1) Replace the integration test tag ID (222) with your unique Rokt Tag ID
// 2) Replace Y.Y.Y with the application version
Rokt.INSTANCE.init("222", "Y.Y.Y", LauncherActivity.this)
...
}
}
Was this article helpful?