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:2.1.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 = "Git_lab_access_token_here"
}
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"/> (for OneCloud Platform, use android:value="https://sixthsense-backend.jpe2-caas1-prod1.caas.jpe2b.r-local.net/mobile"/>)
  1. (Optional) Similarly you can configure the application name that you want to see on the SixthSense dashboard when data is reported for this application.
<meta-data android:name= "com.rakuten.sixthsense.APP_NAME"
android:value="your-custom-app-name"/>

If you do not configure this field, the default application name is used for reporting the data for this application. This option is useful when you have different product flavors (for example, dev, test, production environments) and want data for each of these to be reported separately to the dashboard.

  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 the dashboard. To report handled exceptions use the following SSLogger.

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 = "Git_lab_access_token_here"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}

Add the following to the dependencies block of buildscript.

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

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()