Skip to content

Sentry Flutter Android does not capture any exceptions at all when custom initialization - caused by callback failure, thus would be great to add a log / throw when this happens #1486

@fzyzcjy

Description

@fzyzcjy

Platform

Flutter Mobile

Obfuscation

Disabled

Debug Info

Disabled

Doctor

latest

Version

latest

Steps to Reproduce

Custom initialization:

class MyFlutterApplication : FlutterApplication() {
    override fun onCreate() {
        super.onCreate()
        initSentry()
    }

    fun initSentry() {
        SentryAndroid.init(this) { options ->
            options.dsn = SENTRY_DSN
            val removed = options.integrations.removeAll { it is TempSensorBreadcrumbsIntegration }
            check(removed)
        }
    }

And disable Dart side auto initiailization:

    options
      ..autoInitializeNativeSdk = !Platform.isAndroid
      ......

Then, Sentry.captureException(...).

Extra experiment and possible cause analysis

I have compared two cases:

  1. The standard default way - let Flutter side auto init Android side
  2. The way mentioned above - init Sentry Android manually at FlutterApplication.onCreate, and disable Flutter side from initing Android side

I see both cases call SentryClient._attachClientReportsAndSend and FileSystemTransport.send happily. Indeed, with the following extra logs, I can see "hi 1" and "hi 2" both.

image

I will update my findings here. If I can fix it, hopefully this issue can be used as a future reference for who wants to manually initialize sentry.

Expected Result

See exception sent to sentry server

Actual Result

No exception sent to sentry server

Are you willing to submit a PR?

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions