Post on 12-Apr-2017
eXtreme eXception eXpectation
Crashes suck!
IT´S DANGEROUS TO GO ALONE! TAKE THIS!
What what, what, what?
It ain’t nuthin’ but a code thang
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
public class ExceptionHandler implements Thread.UncaughtExceptionHandler {@Overridepublic void uncaughtException(Thread thread, Throwable ex) {// Do things with the thread and the exception hereTroidolytics.defaultHandler.uncaughtException(thread, ex);}
}
But what happens when internet go boo boo?
Cache and Carry
Crash reporters cache the exception reports and send them the first time your app is opened with internet access.
But da app sux!!!!1!!!!1!!!11!
What if your crash disappoints the user and they never start the app again?
public class ConnectivityBroadcastReceiver extends BroadcastReceiver {@Override
public void onReceive(Context context, Intent intent) {ConnectivityManager cm = (ConnectivityManager)context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();if(netInfo != null && netInfo.isConnected()){
// Send the reports here, you should probably start a serviceTroidolytics.sendReports(); // #inspired
}}
}
<receiver android:name="zg.troido.crashme.ConnectivityBroadcastReceiver"android:enabled="true"android:exported="true"android:label="ConnectivityChange">
<intent-filter><action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter></receiver>
It’s not only your app that’s not responding
compile 'com.github.anrwatchdog:anrwatchdog:1.1.+'
if (!BuildConfig.DEBUG) {new ANRWatchDog().start();
}
WHY DO WE NEED THIS?
SUPERPOWERS
grouping crashesos version
device modelram / cpu
What what, what, what?
Log EVERYTHINGcaught exceptions, custom messages,variable states
} catch (Exception e) { Crashlytics.logException(e);
ACRA.getErrorReporter().handleException(e); }
And if you are special and want custom logging?
Exporting crashes
WTF is... ACRA?
init@ReportsCrashes( formUri = "http://www.backendofyourchoice.com/reportpath", formKey = "" // This is required for backward compatibility but not used)public class AcraApplication extends Application {...}
init public void onCreate() { super.onCreate(); ACRA.init(this); }
WTF is Crashlytics?
init
get fabric plugin include crashlytics
TAKEOUT
know your appPlan-Do-Check-Adjust
stability matters
Adriano OrioliHrvoje Kozak
Troido