Android agent

Installing the agent

To install SixthSense Mobile Monitoring Android SDK add the dependency to your build.gradle file dependencies block

implementation("com.rakuten.sixthsense.observability:mobilemonitoring:1.2.0")

Add the following lines to the repositories block

repositories {
maven {
url "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/21/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "sixthsense_package_token"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

Configuring the agent

Configuration is done via AndroidManifest.xml.

  1. Configure the Access Token in the application tag.
<meta-data android:name="com.rakuten.sixthsense.ACCESS_TOKEN"
android:value=="access-token-here"/>

For accessing the token, see Accessing your Access Token under Getting started with the Observability Portal.

  1. Similarly configure reporting Base URL.
<meta-data android:name= "com.rakuten.sixthsense.BASE_URL"
android:value="https://http-collector-observability.sixthsense.rakuten.com/mobile"/>
  1. Initialize SSObservability in the OnCreate callback of your application subclass:
class App : Application() {
override fun onCreate() {
super.onCreate()
// Initialise error handling here
SSObservability.init(this)
}
}

This will capture crashes and ANRs and list them on dashboard. To report handled exceptions use the SSLogger as shown below.

try {
...
}
catch (e: Exception) {
SSLogger.log(e)
...
}

In order to get de-obfuscated stack traces (when using R8 minification and so on) add the following to your ProGuard config file (proguard.cfg, proguard-android.txt, proguard-rules.pro, and so on).

-keepattributes Exceptions, Signature, InnerClasses, LineNumberTable, SourceFile, EnclosingMethod
  1. OkHttp3, Retrofit and Volley integration.

To capture all network calls made from your application using OkHttp3 client directly or Retrofit using OkHttp3 or Volley using HttpURLConnection add the SSNetworkPlugin which will auto instrument for all the respective clients in the project.

Add these lines to repositories specified for downloading plugins (in buildscript)

repositories {
maven {
url "https://artifacts-observability.sixthsense.rakuten.com/api/v4/projects/21/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "sixthsense_package_token"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

Add the following to the dependencies block of buildscript.

dependencies {
classpath "com.rakuten.sixthsense.mobilemonitoring:SSNetworkPlugin:1.2.0"
}

Finally apply the plugin in the module level build.gradle.

apply plugin: "SSNetworkPlugin"

The requirements for the above Http Clients auto instrumentation are

  • Android Gradle Plugin 7.1+
  • Gradle version - 7.2+

Alternatively, if you want to manually instrument OkHttp clients to capture network calls made only from specific places in the code, you need to add SSEventListener as event listener when you create your OkHttpClient instance as in the following code.

OkHttpClient.Builder().eventListener(SSEventListener()).build()`