countly-sdk-android icon indicating copy to clipboard operation
countly-sdk-android copied to clipboard

Crashes get lost

Open am3n opened this issue 3 years ago • 2 comments

When the user is offline or server is stopped, and a crash occurs, the crash get lost! After many tests and read the this sdk source code, i found the issue. When an error occurs, the app stops quickly and the caching not apply..

https://github.com/Countly/countly-sdk-android/blob/dd79709acce513d4c8564fe06c66ab39d9a02de1/sdk/src/main/java/ly/count/android/sdk/CountlyStore.java

and i solved it temporarily by adding a long run Thread.UncaughtExceptionHandler to my App.kt class, to delay the stop time

val def = Thread.getDefaultUncaughtExceptionHandler()
val handler = Thread.UncaughtExceptionHandler { t, e ->
    sleep(500)
    def?.uncaughtException(t, e)
}
Thread.setDefaultUncaughtExceptionHandler(handler)

val config = CountlyConfig(this, countlyAppKey, countlyUrl)
...
Countly.sharedInstance().init(config)

am3n avatar May 01 '21 12:05 am3n

Hello, could you show you full SDK initialisation code? Your code seems to indicated that there are some other calls between creating the config object and initialising the sdk.

ArtursKadikis avatar May 01 '21 13:05 ArtursKadikis

        val config = CountlyConfig(this, countlyAppKey, countlyUrl)
        config.setApplication(this)
        config.setLoggingEnabled(true)
        config.setEventQueueSizeToSend(3)
        config.setUpdateSessionTimerDelay(10)
        config.setIdMode(DeviceId.Type.ADVERTISING_ID)
        config.setShouldIgnoreAppCrawlers(false)
        config.setViewTracking(true)
        config.setAutoTrackingUseShortName(true)
        config.enableCrashReporting()
        config.setCustomCrashSegment(mapOf(
            "debug" to if (BuildConfig.DEBUG) "true" else "false",
            "app_version_code" to BuildConfig.VERSION_CODE,
            "devices" to sh("Main").getString("devices", "")
        ))
        Countly.sharedInstance().init(config)
        Countly.sharedInstance().requestQueueOverwriteAppKeys()
        Countly.sharedInstance().crashes().addCrashBreadcrumb("App > onCreate() > init countly")

am3n avatar May 04 '21 22:05 am3n