Integrating and Initializing the SDK
The Rokt SDK for Android Native Applications can be used by Rokt Partners to display overlay or embedded placements or by Rokt Brands to record conversions for their campaigns. The Rokt SDK for Android is deployed using Maven and Gradle. This step by step guide assumes that you are familiar with Gradle and know how to install a plugin for Android development. Note on ProGuard Rules: The Rokt SDK for Android contains ProGuard rules and does not require additional configuration.
All use cases of the SDK will follow the same initial steps to integrate and initialize the SDK in-app. At a high level, these steps are:
- Set up a workspace and enable Rokt Gradle repository
- Add the Rokt Placement plugin.
- Add the Rokt Android SDK module
- 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.
Step 1: Set up a workspace and enable Rokt Gradle repository
To set up a repository follow the instructions from https://docs.gradle.org/current/userguide/declaring_repositories.html
Step 2: Add the Rokt Placement plugin
Add the Rokt Widget plugin repository url in the build.gradle file for the project.
// file => build.gradle (Project: ....)
allprojects {
repositories {
google()
jcenter()
maven {
url "https://rokt-eng-us-west-2-mobile-sdk-artefacts.s3.amazonaws.com"
}
}
}
Step 3: Add the Rokt Android SDK module
Add the Rokt Android SDK module to build.gradle for Module
// file => build.gradle (Module: ...)
dependencies {
...
// Note: 3.3.4 reflects the latest version of the Rokt Android SDK.
implementation 'com.rokt:roktsdk:3.3.4'
...
}
Step 4: Initialize the Rokt Android SDK
Initialize the Rokt SDK prior to using it in any Activity. The recommended way of calling the init method is inside the Launcher Activity class
Please contact Rokt for the Rokt Tag ID associated with your account. In order to test your integration, you can use the Rokt Tag ID below. Please note that this will need to be replaced by your unique Rokt Tag ID.
Test Integration Tag ID: 222
Kotlin
import com.rokt.roktsdk.Rokt
public class LauncherActivity: 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.init("222", "Y.Y.Y", this@LauncherActivity)
...
}
}
Java
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)
...
}
}
The subsequent steps will depend on the use case of the integration. More details can be found here: