Monitors errors and reports exceptions, collecting diagnostic information and notifying development teams for quick issue resolution. Supports configuration of error types and uploading symbol files for full stacktraces.
Error monitoring & exception reporter for Kotlin with Multiplatform support
Detect crashes in your applications using Kotlin Multiplatform: collecting diagnostic information and immediately notifying your development team, helping you to understand and resolve issues as fast as possible.
The Bugsnag client should be initialized as early as possible in your application lifecycle. On Android this is typically in the onCreate method of your Application class, while on iOS this is typically in the didFinishLaunchingWithOptions method of your AppDelegate class, or in the init method of your App class. Since we have Kotlin Multiplatform support, you can share most of your configuration code:
// BugsnagStartup.ktimport com.bugsnag.kmp.Bugsnag
import com.bugsnag.kmp.Configuration
funstartBugsnag(configuration: Configuration) {
// common configuration here
configuration.addMetadata("App", "multiplatform", true)
Bugsnag.start(configuration)
}
Bugsnag.start should still be called in a platform-specific location:
// don't accidentally import 'com.bugsnag.android.Configuration' if you want common configurationimport com.bugsnag.kmp.Configuration
classMyApp : Application() {
overridefunonCreate() {
super.onCreate()
startBugsnag(Configuration(this, "your-api-key"))
}
}
The Bugsnag client can be configured to ignore certain types of errors. By default, all error types are enabled. You can enable or disable error types by calling the setEnabledErrorTypes method on the Configuration object.
In the bugsnag-kmp each platform-specific error type can be configured independently as part of the common source set:
import com.bugsnag.kmp.Configuration
// bugsnag-kmp includes a convenience extension function to set enabled error types in a lambdaimport com.bugsnag.kmp.setEnabledErrorTypes
configuration.setEnabledErrorTypes {
iosOoms = false
}
Showing full stacktraces
To see fully symbolicated Kotlin and native stacktraces in your dashboard, we recommend using the bugsnag-cli tool. This will find and upload the symbol files for each platform in your Kotlin Multiplatform project:
# upload the symbol files for the current build
bugsnag-cli upload android-aab app --api-key=your-api-key
bugsnag-cli upload xcode-archive iosApp --api-key=your-api-key
If your API-key is defined in the AndroidManifest.xml and Info.plist files, you can omit the --api-key argument. The CLI will automatically find the API key in your project files. These steps are typically added to your CI/CD pipeline, so that the symbol files are uploaded automatically after each build.