Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

check for androidx availability on runtime #356

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ public void register(final @NotNull IHub hub, final @NotNull SentryOptions optio
options.isEnableSessionTracking());

if (options.isEnableSessionTracking()) {
watcher = new LifecycleWatcher(hub, options.getSessionTrackingIntervalMillis());
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);

options.getLogger().log(SentryLevel.DEBUG, "SessionTrackingIntegration installed.");
try {
bruno-garcia marked this conversation as resolved.
Show resolved Hide resolved
Class.forName("androidx.lifecycle.DefaultLifecycleObserver");
Class.forName("androidx.lifecycle.ProcessLifecycleOwner");
watcher = new LifecycleWatcher(hub, options.getSessionTrackingIntervalMillis());
ProcessLifecycleOwner.get().getLifecycle().addObserver(watcher);

options.getLogger().log(SentryLevel.DEBUG, "SessionTrackingIntegration installed.");
} catch (ClassNotFoundException e) {
options
.getLogger()
.log(
SentryLevel.INFO,
"androidx.lifecycle is not available, SessionTrackingIntegration won't be installed",
e);
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions sentry-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ dependencies {

implementation(project(":sentry-android"))

// how to exclude androidx if release health feature is disabled
// implementation(project(":sentry-android")) {
// exclude(group = "androidx.lifecycle", module = "lifecycle-process")
// exclude(group = "androidx.lifecycle", module = "lifecycle-common-java8")
// }

implementation(Config.Libs.appCompat)

// debugging purpose
Expand Down