Migrate from sentry-android 4.3.0 to 5.0.0

Learn about migrating from Sentry Android SDK 4.3.0 to 5.0.0.

You may remove android:extractNativeLibs="true" meta-data in the AndroidManifest file or android.bundle.enableUncompressedNativeLibs=false in the gradle.properties file if you're using the Android Native Development Kit. Sentry can now symbolicate events with the default value of extractNativeLibs and android.bundle.enableUncompressedNativeLibs.

Sentry#startTransaction by default does not bind created transaction to the scope. To start transaction with binding to the scope, use one of the new overloaded startTransaction methods taking bindToScope parameter and set it to true. Bound transaction can be retrieved with Sentry#getSpan.

All SDK methods have been annotated with JetBrains Annotations: @Nullable and @NotNull. Kotlin compiler respects these annotations, so in Kotlin code, some fields that were recognized as not-null, are now nullable, and the other way around.

SentryBaseEvent#getOriginThrowable has been deprecated in favor of SentryBaseEvent#getThrowable, and SentryBaseEvent#getThrowable now returns the unwrapped throwable.

SentryOptions#getCacheDirSize has been deprecated in favor of SentryOptions#getMaxCacheItems.

InvalidDsnException has been removed. It is replaced by IllegalArgumentException.

EventProcessor interface has a new default method which could break the instantiation when using trailing lambdas.

Old:

Copied
SentryOptions#addEventProcessor { event, _ -> event }

New:

Copied
SentryOptions#addEventProcessor(object : EventProcessor {
    override fun process(event: SentryEvent, hint: Hint): SentryEvent? {
        return event
    }
})

A random generated installationId replaces Settings.Secure.ANDROID_ID, which has been removed. This may affect the number of unique users displayed on the Issues page and Alerts. If you always set a custom user using Sentry.setUser(customUser), the behavior has not changed. While you don't have to make any update, if you want to maintain the old behavior, use the following code snippet:

Copied
User user = new User();
user.setId(Settings.Secure.ANDROID_ID);

Sentry.setUser(user);

SentryOptions#setEnableSessionTracking(boolean) is deprecated in favor of SentryOptions#setEnableAutoSessionTracking(boolean). It will be removed in future.

Old:

Copied
SentryAndroid.init(this, options -> {
    options.setEnableSessionTracking(false);
});

New:

Copied
SentryAndroid.init(this, options -> {
    options.setEnableAutoSessionTracking(false);
});

io.sentry.session-tracking.enable AndroidManifest meta-data is deprecated in favor of io.sentry.auto-session-tracking.enable. It will be removed in future.

Old:

AndroidManifest.xml
Copied
<application>
    <meta-data
    android:name="io.sentry.session-tracking.enable"
    android:value="false"
  />
</application>

New:

AndroidManifest.xml
Copied
<application>
    <meta-data
    android:name="io.sentry.auto-session-tracking.enable"
    android:value="false"
  />
</application>
Was this helpful?
Help improve this content
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").