Kotlin Multiplatform
Kotlin Multiplatform lets you write code once and use it on various platforms. It makes building apps easier and more efficient by sharing common code, while still benefitting from native capabilities.
Sentry's Kotlin Multiplatform SDK builds on top of multiple Sentry SDKs, allowing developers to share code between platforms while being able to integrate Sentry's features into their applications. Installing this SDK will enable native crash reporting and automatic breadcrumbs for app lifecycle and UI events.
Don't already have an account and Sentry project established? Head over to sentry.io, then return to this page.
Xcode 16 support starts with Sentry Cocoa SDK version 8.36.0
or higher.
Starting May 1, 2024, Apple requires all apps submitted to the App Store to provide a list of privacy-related APIs they use. Use Sentry Cocoa SDK version 8.25.0
or higher to ensure compliance with these requirements. Follow our Apple Privacy Manifest guide to learn more.
Sentry captures data by using an SDK within your application’s runtime.
To install the Kotlin Multiplatform SDK, you need to add the following to your build.gradle.kts
file in your shared module:
shared/build.gradle.kts
plugins {
id("io.sentry.kotlin.multiplatform.gradle") version "0.10.0"
}
The plugin installs the Sentry KMP dependency. If you're using the Cocoapods plugin, it will also install the Sentry Cocoa dependency.
Configuration should happen as early as possible in your application's lifecycle.
SentrySetup.kt
import io.sentry.kotlin.multiplatform.Sentry
fun initializeSentry() {
Sentry.init { options ->
options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
}
}
This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
import io.sentry.kotlin.multiplatform.Sentry
fun captureError() {
try {
throw Exception("This is a test.")
} catch (e: Exception) {
Sentry.captureException(e)
}
}
Learn more about manually capturing an error or message in our Usage documentation.
To view and resolve the recorded error, log into sentry.io and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").