Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AbstractMethodError when getting Lifecycle #2228

Merged
merged 9 commits into from
Sep 6, 2022
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Fixed AbstractMethodError when getting Lifecycle ([#2228](https://github.com/getsentry/sentry-java/pull/2228))
- Avoid sending empty profiles ([#2232](https://github.com/getsentry/sentry-java/pull/2232))

## 6.4.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,29 @@ private void addObserver(final @NotNull IHub hub) {
if (this.options == null) {
return;
}

watcher =
new LifecycleWatcher(
hub,
this.options.getSessionTrackingIntervalMillis(),
this.options.isEnableAutoSessionTracking(),
this.options.isEnableAppLifecycleBreadcrumbs());
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);
options.getLogger().log(SentryLevel.DEBUG, "AppLifecycleIntegration installed.");

try {
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);
options.getLogger().log(SentryLevel.DEBUG, "AppLifecycleIntegration installed.");
} catch (Throwable e) {
// This is to handle a potential 'AbstractMethodError' gracefully. The error is triggered in
// connection with conflicting dependencies of the androidx.lifecycle.
// //See the issue here: https://github.com/getsentry/sentry-java/pull/2228
watcher = null;
options
.getLogger()
.log(
SentryLevel.ERROR,
"AppLifecycleIntegration failed to get Lifecycle and could not be installed.",
e);
}
}

private void removeObserver() {
Expand Down