Skip to content

Commit 08e56dd

Browse files
committed
Update README
1 parent c0700bc commit 08e56dd

File tree

1 file changed

+45
-26
lines changed

1 file changed

+45
-26
lines changed

packages/firebase_crashlytics/README.md

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,59 @@ For Flutter plugins for other Firebase products, see [README.md](https://github.
1212

1313
To use the `firebase_crashlytics` plugin, follow the [plugin installation instructions](https://pub.dartlang.org/packages/firebase_crashlytics#pub-pkg-tab-installing).
1414

15+
The following instructions are from [the official installation page](https://firebase.google.com/docs/crashlytics/get-started-new-sdk).
16+
1517
### Android integration
1618

1719
Enable the Google services by configuring the Gradle scripts as such:
1820

19-
1. Add the Fabric repository to the `[project]/android/build.gradle` file.
20-
```
21-
repositories {
22-
google()
23-
jcenter()
24-
// Additional repository for fabric resources
25-
maven {
26-
url 'https://maven.fabric.io/public'
21+
1. Check that you have Google's Maven repository in your **project-level** `build.gradle` file (`[project]/android/build.gradle`).
22+
23+
```gradle
24+
buildscript {
25+
repositories {
26+
// Add this
27+
google()
28+
29+
// ... you may have other repositories
30+
}
31+
}
32+
allprojects {
33+
repositories {
34+
// and this
35+
google()
36+
37+
// ...
2738
}
2839
}
2940
```
3041

31-
2. Add the following classpaths to the `[project]/android/build.gradle` file.
42+
2. Add the following classpaths to your **project-level** `build.gradle` file (`[project]/android/build.gradle`).
43+
3244
```gradle
33-
dependencies {
34-
// Example existing classpath
35-
classpath 'com.android.tools.build:gradle:3.2.1'
36-
// Add the google services classpath
37-
classpath 'com.google.gms:google-services:4.3.0'
38-
// Add fabric classpath
39-
classpath 'io.fabric.tools:gradle:1.26.1'
45+
buildscript {
46+
dependencies {
47+
// Check that you have the Google Services Gradle plugin v4.3.2 or later (if not, add it).
48+
classpath 'com.google.gms:google-services:4.3.3'
49+
// Add the Crashlytics Gradle plugin.
50+
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04'
51+
52+
// ... you may have other classpaths
53+
}
4054
}
4155
```
4256

43-
2. Apply the following plugins in the `[project]/android/app/build.gradle` file.
57+
3. Apply the following plugins in your **app-level** `build.gradle` file (`[project]/android/app/build.gradle`).
58+
4459
```gradle
4560
// ADD THIS AT THE BOTTOM
46-
apply plugin: 'io.fabric'
4761
apply plugin: 'com.google.gms.google-services'
62+
apply plugin: 'com.google.firebase.crashlytics'
4863
```
4964

5065
*Note:* If this section is not completed, you will get an error like this:
51-
```
66+
67+
```console
5268
java.lang.IllegalStateException:
5369
Default FirebaseApp is not initialized in this process [package name].
5470
Make sure to call FirebaseApp.initializeApp(Context) first.
@@ -64,18 +80,20 @@ Add the Crashlytics run scripts:
6480
1. From Xcode select `Runner` from the project navigation.
6581
1. Select the `Build Phases` tab.
6682
1. Click `+ Add a new build phase`, and select `New Run Script Phase`.
67-
1. Add `${PODS_ROOT}/Fabric/run` to the `Type a script...` text box.
83+
1. Add `${PODS_ROOT}/FirebaseCrashlytics/run` to the `Type a script...` text box.
6884
1. If you are using Xcode 10, add the location of `Info.plist`, built by your app, to the `Build Phase's Input Files` field.
6985
E.g.: `$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)`
7086

7187
### Use the plugin
7288

7389
Add the following imports to your Dart code:
90+
7491
```dart
7592
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
7693
```
7794

7895
Setup `Crashlytics`:
96+
7997
```dart
8098
void main() {
8199
// Set `enableInDevMode` to true to see reports while in debug mode
@@ -91,20 +109,21 @@ void main() {
91109
}
92110
```
93111

94-
Overriding `FlutterError.onError` with `Crashlytics.instance.recordFlutterError` will automatically catch all
95-
errors that are thrown from within the Flutter framework.
96-
If you want to catch errors that occur in `runZoned`,
97-
you can supply `Crashlytics.instance.recordError` to the `onError` parameter:
112+
Overriding `FlutterError.onError` with `Crashlytics.instance.recordFlutterError` will automatically catch all errors that are thrown from within the Flutter framework.
113+
114+
If you want to catch errors that occur in `runZoned`, you can supply `Crashlytics.instance.recordError` to the `onError` parameter:
115+
98116
```dart
99117
runZoned<Future<void>>(() async {
100118
// ...
101119
}, onError: Crashlytics.instance.recordError);
102-
```
120+
```
103121

104122
## Result
105123

106124
If an error is caught, you should see the following messages in your logs:
107-
```
125+
126+
```shell
108127
flutter: Flutter error caught by Crashlytics plugin:
109128
// OR if you use recordError for runZoned:
110129
flutter: Error caught by Crashlytics plugin <recordError>:

0 commit comments

Comments
 (0)