Skip to content

Commit 2c754fd

Browse files
authored
Convert crash quickstart to crashlytics (firebase#501)
2 parents 8ccb6d6 + a7b5200 commit 2c754fd

File tree

5 files changed

+24
-25
lines changed

5 files changed

+24
-25
lines changed

crash/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Firebase Crash Quickstart
2-
=============================
1+
Firebase Crashlytics Quickstart
2+
===============================
33

44
Introduction
55
------------
66

7-
- [Read more about Firebase Crash Reporting](https://firebase.google.com/docs/crash)
7+
- [Read more about Firebase Crashlytics](https://firebase.google.com/docs/crashlytics)
88

99
Getting Started
1010
---------------

crash/app/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apply plugin: 'com.android.application'
2+
apply plugin: 'io.fabric'
3+
24
check.dependsOn 'assembleDebugAndroidTest'
35

46
android {
@@ -35,7 +37,7 @@ dependencies {
3537
implementation 'com.android.support:appcompat-v7:27.1.1'
3638

3739
implementation 'com.google.firebase:firebase-core:15.0.2'
38-
implementation 'com.google.firebase:firebase-crash:15.0.2'
40+
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.2'
3941

4042
testImplementation 'junit:junit:4.12'
4143
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

crash/app/src/main/java/com/google/samples/quickstart/crash/MainActivity.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@
2323
import android.widget.Button;
2424
import android.widget.CheckBox;
2525

26-
import com.google.firebase.crash.FirebaseCrash;
26+
import com.crashlytics.android.Crashlytics;
2727

2828
/**
2929
* 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.
3131
* - Automatically Report uncaught crashes.
3232
*
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().
3434
*
3535
* Check https://console.firebase.google.com to view and analyze your crash reports.
3636
*
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.
3938
*/
4039
public class MainActivity extends AppCompatActivity {
4140

@@ -54,32 +53,30 @@ protected void onCreate(Bundle savedInstanceState) {
5453
crashButton.setOnClickListener(new View.OnClickListener() {
5554
@Override
5655
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.");
6058

6159
// 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
6361
// report the crash.
6462
if (catchCrashCheckBox.isChecked()) {
6563
try {
6664
throw new NullPointerException();
6765
} 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]
7270
}
7371
} else {
7472
throw new NullPointerException();
7573
}
7674
}
7775
});
7876

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]
8481
}
8582
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<resources>
2-
<string name="app_name">Firebase Crash</string>
2+
<string name="app_name">Firebase Crashlytics</string>
33
<string name="crash_button_label">Cause Crash</string>
44
<string name="catch_crash_checkbox_label">Catch Crash</string>
55
</resources>

crash/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ buildscript {
55
jcenter()
66
mavenLocal()
77
maven { url 'https://maven.google.com' }
8+
maven { url 'https://maven.fabric.io/public' }
89
}
910
dependencies {
1011
classpath 'com.android.tools.build:gradle:3.1.2'
1112
classpath 'com.google.gms:google-services:3.3.0'
12-
// NOTE: Do not place your application dependencies here; they belong
13-
// in the individual module build.gradle files
13+
classpath 'io.fabric.tools:gradle:1.25.1'
1414
}
1515
}
1616

0 commit comments

Comments
 (0)