Cannot capture exception with Sentry

Viewed 514

I'm initializing my Sentry intance like this:

Sentry.init(options -> {
            options.setDsn("https://****@****.ingest.sentry.io/****");
            options.setTracesSampleRate(1.0);
            options.setDebug(true);
        });

I'm them capturing an exception like this:

Sentry.captureException(new Error("Generic error"));

When I capture something like that, this is my result I get:

[10.07 13:01:43.027] INFO: [Lobby-1] [13:01:42 INFO]: DEBUG: Capturing event: 187ae6cca0604c72b84a0429d3bc95c8
[10.07 13:01:43.027] INFO: [Lobby-1] [13:01:42 INFO]: INFO: Session is null on scope.withSession
[10.07 13:01:43.027] INFO: [Lobby-1] [13:01:42 INFO]: ERROR: Request failed, API returned 400
[10.07 13:01:43.027] INFO: [Lobby-1] [13:01:42 INFO]: ERROR: {"detail":"empty envelope"}

I've also tried by just throwing the error and let Sentry handle the unhandled error but that doesn't log anything except the thrown error.

I also some posts talking about a specific gson version. Even though I don't use it in my project I added it to my gradle dependencies but that still results in the same issue. These are the currently installed GSON versions:

enter image description here

1 Answers

This error can happen if you have an older version of Gson than Sentry requires. You might not depend on Gson directly but it might be a transient dependency.

Sentry depends on Gson version 2.8.5 and when an older version is resolved this issue can happen. Make sure to add this version or higher to your gradle project.

Note that Sentry is working on dropping the dependency to Gson which will result in a dependency-free package.

Related