Android uncaught exception in Thread is not sent to sentry

Hi, i am trying to send uncaught exception in Java Android. In new Thread i get in logcat this error

2019-07-10 09:44:48.876 19024-19578/? W/System.err: java.lang.RuntimeException: You shouldn't call this!
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at com.android24gate.logistic.MainActivity.sentryTest(MainActivity.java:715)
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at com.android24gate.logistic.MyJavascriptAppInterface.sentryTest(MyJavascriptAppInterface.java:44)
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at android.os.MessageQueue.nativePollOnce(Native Method)
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at android.os.MessageQueue.next(MessageQueue.java:326)
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at android.os.Looper.loop(Looper.java:181)
2019-07-10 09:44:48.876 19024-19578/? W/System.err:     at android.os.HandlerThread.run(HandlerThread.java:65)

i know that exception should be cached on disk and sent later. But it never happened.

Can you help, where is the problem?

Thanks

Can you provide more details about your app and setup?

Yes, it is android java application. On MainActivity it initialize sentry by DSN

Context ctx = this.getApplicationContext();
Sentry.init("dsn", new AndroidSentryClientFactory(ctx));

after this i open webview, which communicates with android by JavascriptInterface, from where i call MainActivity functions. Any of this call is automatically separated thread, if the exception raise during this call, uncaught exception is never sent to sentry.

I also have in root directory sentry.properties in app directory, but this doesnt work. DSN is never found so i expect that sentry never found this file.

In app/build.gradle i initialize sentry like this

apply plugin: 'io.sentry.android.gradle'

sentry {
    // Disables or enables the automatic configuration of proguard
    // for Sentry.  This injects a default config for proguard so
    // you don't need to do it manually.
    autoProguardConfig true

    // Enables or disables the automatic upload of mapping files
    // during a build.  If you disable this you'll need to manually
    // upload the mapping files with sentry-cli when you do a release.
    autoUpload true
}

dependencies {
implementation ‘io.sentry:sentry-android:1.7.23’
implementation ‘org.slf4j:slf4j-android:1.7.25’

what else i should describe?

@24gate I’d first try to manually capture and send an error to Sentry to make sure your Sentry init and setup is correct (I’m assuming you are not using the literal "dsn" and using your actual DSN, otherwise there’s your problem :slight_smile:).

If that works, I’d play with some of the queue and timeout settings mentioned here: https://docs.sentry.io/clients/java/config/#uncaught-exception-handler

Thanks, of course i tried and it works, no problem,
but in that loop it is never logged.

I will go through the settings, but i hope that default settings should be ok?

The settings without sentry.properties file working, will be problem :frowning:

For the sentry.properties file not being picked up, I’d investigate your build pipeline (Gradle settings etc). For the exception not being reported, I am hoping someone else from the forums would jump and help as this is the limit for my Java and Android knowledge :smiley:

@24gate Could you please share with us a repro for the unhandled exception not being caught?