Kotlin

How to configure rollbar-java to work with your Kotlin app

Installation

Maven

<dependencies>
  <dependency>
    <groupId>com.rollbar</groupId>
      <artifactId>rollbar-java</artifactId>
      <version>1.3.1</version>
  </dependency>
</dependencies>

Gradle

implementation('com.rollbar:rollbar-java:1.+')
  1. Configure Rollbar
import com.rollbar.notifier.Rollbar
import com.rollbar.notifier.config.ConfigBuilder

import scala.util.control.NonFatal

val config = ConfigBuilder.withAccessToken(sys.env("ROLLBAR_ACCESSTOKEN"))
      .language("kotlin")
      .codeVersion("1.0.0")
      .environment("production")
      .build();

val rollbar = new Rollbar(config)
  1. Send an error and a message.
rollbar.error(exception);
rollbar.info("This is an info message");

These two items should appear in your project's dashboard within a few seconds.

📘

For more information on rollbar-java, please see the docs here.