23
23
import android .widget .Button ;
24
24
import android .widget .CheckBox ;
25
25
26
- import com .google . firebase . crash . FirebaseCrash ;
26
+ import com .crashlytics . android . Crashlytics ;
27
27
28
28
/**
29
29
* This Activity shows the different ways of reporting application crashes.
30
- * - Report caught crashes with Crash.report() .
30
+ * - Report non-fatal exceptions that are caught by your app .
31
31
* - Automatically Report uncaught crashes.
32
32
*
33
- * It also shows how to add log messages to crash reports using Crash. log().
33
+ * It also shows how to add log messages to crash reports using log().
34
34
*
35
35
* Check https://console.firebase.google.com to view and analyze your crash reports.
36
36
*
37
- * Check https://firebase.google.com/docs/crash/android for more on
38
- * Firebase Crash on Android.
37
+ * Check https://firebase.google.com/docs/crashlytics for more information on Firebase Crashlytics.
39
38
*/
40
39
public class MainActivity extends AppCompatActivity {
41
40
@@ -54,32 +53,30 @@ protected void onCreate(Bundle savedInstanceState) {
54
53
crashButton .setOnClickListener (new View .OnClickListener () {
55
54
@ Override
56
55
public void onClick (View v ) {
57
- // Log that crash button was clicked. This version of Crash.log() will include the
58
- // message in the crash report as well as show the message in logcat.
59
- FirebaseCrash .logcat (Log .INFO , TAG , "Crash button clicked" );
56
+ // Log that crash button was clicked.
57
+ Crashlytics .log (Log .INFO , TAG , "Crash button clicked." );
60
58
61
59
// If catchCrashCheckBox is checked catch the exception and report is using
62
- // Crash.report(). Otherwise throw the exception and let Firebase Crash automatically
60
+ // logException(), Otherwise throw the exception and let Crashlytics automatically
63
61
// report the crash.
64
62
if (catchCrashCheckBox .isChecked ()) {
65
63
try {
66
64
throw new NullPointerException ();
67
65
} catch (NullPointerException ex ) {
68
- // [START log_and_report ]
69
- FirebaseCrash . logcat (Log .ERROR , TAG , "NPE caught" );
70
- FirebaseCrash . report (ex );
71
- // [END log_and_report ]
66
+ // [START crashlytics_log_and_report ]
67
+ Crashlytics . log (Log .ERROR , TAG , "NPE caught! " );
68
+ Crashlytics . logException (ex );
69
+ // [START crashlytics_log_and_report ]
72
70
}
73
71
} else {
74
72
throw new NullPointerException ();
75
73
}
76
74
}
77
75
});
78
76
79
- // Log that the Activity was created. This version of Crash.log() will include the message
80
- // in the crash report but will not be shown in logcat.
81
- // [START log_event]
82
- FirebaseCrash .log ("Activity created" );
83
- // [END log_event]
77
+ // Log that the Activity was created.
78
+ // [START crashlytics_log_event]
79
+ Crashlytics .log ("Activity created" );
80
+ // [END crashlyticslog_event]
84
81
}
85
82
}
0 commit comments