Skip to content

Crash when closing sentry #2601

Description

@bmarty

Integration

sentry-android

Build System

Gradle

AGP Version

7.6

Proguard

Enabled

Version

6.15.0

Steps to Reproduce

Call Sentry.close()

Expected Result

No crash

Actual Result

The application crashes.

Here is the stack trace:

Thread: main, Exception: java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.lifecycle.LifecycleRegistry.removeObserver, parameter observer
at androidx.lifecycle.LifecycleRegistry.removeObserver(LifecycleRegistry.kt:4)
at io.sentry.android.core.AppLifecycleIntegration$$ExternalSyntheticLambda0.run(R8$$SyntheticClass:12)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

I believe that the issue is coming from these lines

When removeObserver is invoked, the watcher is null.

This is not new code, but the crash is occurring only now, I am not sure why.

Also this does not crash on every device. Crash on Android 10.

Metadata

Metadata

Assignees

Labels

BugIssue type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions