Android SDK ⁠-⁠ Initializing the SDK

The following line will install the tracker and with it the SDK for you to take advantage of all tracker features.

Add it in your root build.gradle at the end of repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
      mavenCentral()
      maven { url 'https://jitpack.io' }
    }
}

Add the dependency in your app build.gradle file:

dependencies {
    implementation("com.github.openreplay:android:Tag")
}

When instantiating OpenReplay’s tracker, there are several configuration options you can provide to customize many aspects of the recording and the recording experience. You must set the projectKey option in the constructor. You can get this value from your OpenReplay dashboard under ‘Preferences > Projects’.

Add the following code to your MainActivity.kt file:

// MainActivity.kt
import com.openreplay.tracker.OpenReplay

//...

class MainActivity : TrackingActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    // not required if you're using our SaaS version
    OpenReplay.serverURL = "https://your.instance.com/ingest"
    // check out our SDK docs to see available options
    OpenReplay.start(
      applicationContext,
      "projectkey",
      OpenReplay.Options.defaults(),
      onStarted = {
        println("OpenReplay Started")
      })

    // ...
  }
}
// MainActivity.kt
import com.openreplay.tracker.listeners.TrackingActivity

// ...
class MainActivity : TrackingActivity() {
  // ...
}

See how to sanitize data in Android replays for more details.

  • crashes: Bool Enables crashlytics.
  • analytics: Bool Enables analytics tracking of marked views.
  • performances: Bool Enables performance listener.
  • logs: Bool Enables logs listener.
  • screen: Bool Enables screen recorder.
  • wifiOnly: Bool Forces tracker to start only if user has a wifi connection.

If you have any questions about this process, feel free to reach out to us on our Slack or check out our Forum.