Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good idea to initialize Crashlytics, on android's onCreate method?

I'm using Crashlytics for android and it really helped me to fix many of my crashes. But today I had a little problem with it.

When I tried to test crashlytics on 2.3.3 Galaxy S device, which is connected to internet by wi-fi(with proxy), I saw black screen on device for about 2:30 minutes. While debugging; I see that Crashlytics.start(this) code is not async. It waits to establish a connection and thus onCreate method can not be finished by UI thread.(This explains black screen).

I know this a proxy issue(proxy setting is a bit buggy on 2.3.x devices) but waiting for about 2:30 minutes made my app black screen. This worried me that this may happen on any other real life conditions such as poor internet connection.

I will try to put Crashlytics.start(this) function into an asynctask and will try this on every activities onCreate method. (AFAIK there is no method to check isCrashlyticsInitialized)

Does anyone have better idea about this?

Thanks in advance.

LOGCAT:

 10-02 16:01:38.410: D/Crashlytics(1561): Initializing Crashlytics 0.9.11.11 
 10-02 16:04:19.664: E/Crashlytics(1561): Network error while loading Crashlytics settings. Crashes will be cached until the network is available.
[URL=https://settings.crashlytics.com/api/v2/keys/KEY/platforms/android/apps/com.myapp/settings.json?libVersion=0.9.11.11&bundleVersion=441210&shortBundleVersion=2.1];[class java.net.SocketTimeoutException: Connection timed out]
like image 793
Devrim Avatar asked Dec 26 '22 19:12

Devrim


1 Answers

Marc from Crashlytics here. Crashlytics.start() does all the heavy lifting in a background thread in newer versions of the SDK. Your logs indicate you're using v0.9.11. Once you update to the latest version (v1.0.4), you'll be fine keeping Crashlytics.start in the Application subclass. Please contact us at support at crashlytics dot com if you need any help updating!

like image 95
marcr Avatar answered Dec 31 '22 12:12

marcr