diff --git a/packages/firebase_crashlytics/CHANGELOG.md b/packages/firebase_crashlytics/CHANGELOG.md index f358e8835de4..ed1958dd21d3 100644 --- a/packages/firebase_crashlytics/CHANGELOG.md +++ b/packages/firebase_crashlytics/CHANGELOG.md @@ -1,3 +1,12 @@ +## 0.2.0 + +* **Breaking**: Migration to the new Firebase Crashlytics SDK. Follow the [migration guide](https://firebase.google.com/docs/crashlytics/upgrade-sdk?platform=android) to update your app. +* **Breaking**: the following methods have been removed: + * `setUserEmail` + * `setUserEmail` + * `getVersion` + * `isDebuggable` + ## 0.1.3+3 * Fix for missing UserAgent.h compilation failures. diff --git a/packages/firebase_crashlytics/android/build.gradle b/packages/firebase_crashlytics/android/build.gradle index a557dc49e8a2..c06a4bd509b4 100644 --- a/packages/firebase_crashlytics/android/build.gradle +++ b/packages/firebase_crashlytics/android/build.gradle @@ -16,9 +16,6 @@ rootProject.allprojects { repositories { google() jcenter() - maven { - url 'https://maven.fabric.io/public' - } } } @@ -37,7 +34,7 @@ android { } dependencies { - implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9' + implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta03' implementation 'com.google.firebase:firebase-common:16.1.0' implementation 'androidx.annotation:annotation:1.1.0' } diff --git a/packages/firebase_crashlytics/android/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/FirebaseCrashlyticsPlugin.java b/packages/firebase_crashlytics/android/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/FirebaseCrashlyticsPlugin.java index 6de881d1da50..f688661c1901 100644 --- a/packages/firebase_crashlytics/android/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/FirebaseCrashlyticsPlugin.java +++ b/packages/firebase_crashlytics/android/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/FirebaseCrashlyticsPlugin.java @@ -6,8 +6,7 @@ import android.content.Context; import android.util.Log; -import com.crashlytics.android.Crashlytics; -import io.fabric.sdk.android.Fabric; +import com.google.firebase.crashlytics.FirebaseCrashlytics; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugin.common.MethodCall; @@ -42,11 +41,6 @@ private static MethodChannel setup(BinaryMessenger binaryMessenger, Context cont final MethodChannel channel = new MethodChannel(binaryMessenger, "plugins.flutter.io/firebase_crashlytics"); channel.setMethodCallHandler(new FirebaseCrashlyticsPlugin()); - - if (!Fabric.isInitialized()) { - Fabric.with(context, new Crashlytics()); - } - return channel; } @@ -57,11 +51,12 @@ public static void registerWith(Registrar registrar) { @Override public void onMethodCall(MethodCall call, Result result) { + final FirebaseCrashlytics crashlytics = FirebaseCrashlytics.getInstance(); if (call.method.equals("Crashlytics#onError")) { // Add logs. List logs = call.argument("logs"); for (String log : logs) { - Crashlytics.log(log); + crashlytics.log(log); } // Set keys. @@ -69,16 +64,16 @@ public void onMethodCall(MethodCall call, Result result) { for (Map key : keys) { switch ((String) key.get("type")) { case "int": - Crashlytics.setInt((String) key.get("key"), (int) key.get("value")); + crashlytics.setCustomKey((String) key.get("key"), (int) key.get("value")); break; case "double": - Crashlytics.setDouble((String) key.get("key"), (double) key.get("value")); + crashlytics.setCustomKey((String) key.get("key"), (double) key.get("value")); break; case "string": - Crashlytics.setString((String) key.get("key"), (String) key.get("value")); + crashlytics.setCustomKey((String) key.get("key"), (String) key.get("value")); break; case "boolean": - Crashlytics.setBool((String) key.get("key"), (boolean) key.get("value")); + crashlytics.setCustomKey((String) key.get("key"), (boolean) key.get("value")); break; } } @@ -96,30 +91,20 @@ public void onMethodCall(MethodCall call, Result result) { } exception.setStackTrace(elements.toArray(new StackTraceElement[elements.size()])); - Crashlytics.setString("exception", (String) call.argument("exception")); + crashlytics.setCustomKey("exception", (String) call.argument("exception")); // Set a "reason" (to match iOS) to show where the exception was thrown. final String context = call.argument("context"); - if (context != null) Crashlytics.setString("reason", "thrown " + context); + if (context != null) crashlytics.setCustomKey("reason", "thrown " + context); // Log information. final String information = call.argument("information"); - if (information != null && !information.isEmpty()) Crashlytics.log(information); + if (information != null && !information.isEmpty()) crashlytics.log(information); - Crashlytics.logException(exception); + crashlytics.recordException(exception); result.success("Error reported to Crashlytics."); - } else if (call.method.equals("Crashlytics#isDebuggable")) { - result.success(Fabric.isDebuggable()); - } else if (call.method.equals("Crashlytics#getVersion")) { - result.success(Crashlytics.getInstance().getVersion()); - } else if (call.method.equals("Crashlytics#setUserEmail")) { - Crashlytics.setUserEmail((String) call.argument("email")); - result.success(null); } else if (call.method.equals("Crashlytics#setUserIdentifier")) { - Crashlytics.setUserIdentifier((String) call.argument("identifier")); - result.success(null); - } else if (call.method.equals("Crashlytics#setUserName")) { - Crashlytics.setUserName((String) call.argument("name")); + crashlytics.setUserId((String) call.argument("identifier")); result.success(null); } else { result.notImplemented(); diff --git a/packages/firebase_crashlytics/example/android/app/build.gradle b/packages/firebase_crashlytics/example/android/app/build.gradle index 891334951d8d..6bd17182159e 100644 --- a/packages/firebase_crashlytics/example/android/app/build.gradle +++ b/packages/firebase_crashlytics/example/android/app/build.gradle @@ -64,5 +64,5 @@ dependencies { implementation "android.arch.lifecycle:extensions:1.1.1" } -apply plugin: 'io.fabric' apply plugin: 'com.google.gms.google-services' +apply plugin: 'com.google.firebase.crashlytics' diff --git a/packages/firebase_crashlytics/example/android/app/src/androidTest/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/EmbeddingV1ActivityTest.java b/packages/firebase_crashlytics/example/android/app/src/androidTest/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/EmbeddingV1ActivityTest.java index 486cb4978c1b..39bdffc12e98 100644 --- a/packages/firebase_crashlytics/example/android/app/src/androidTest/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/EmbeddingV1ActivityTest.java +++ b/packages/firebase_crashlytics/example/android/app/src/androidTest/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlytics/EmbeddingV1ActivityTest.java @@ -1,4 +1,3 @@ - package io.flutter.plugins.firebase.crashlytics.firebasecrashlytics; import androidx.test.rule.ActivityTestRule; diff --git a/packages/firebase_crashlytics/example/android/app/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlyticsexample/EmbeddingV1Activity.java b/packages/firebase_crashlytics/example/android/app/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlyticsexample/EmbeddingV1Activity.java index 76245da23ea0..b41a0b774914 100644 --- a/packages/firebase_crashlytics/example/android/app/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlyticsexample/EmbeddingV1Activity.java +++ b/packages/firebase_crashlytics/example/android/app/src/main/java/io/flutter/plugins/firebase/crashlytics/firebasecrashlyticsexample/EmbeddingV1Activity.java @@ -1,4 +1,3 @@ - package io.flutter.plugins.firebase.crashlytics.firebasecrashlyticsexample; import android.os.Bundle; diff --git a/packages/firebase_crashlytics/example/android/build.gradle b/packages/firebase_crashlytics/example/android/build.gradle index faeab902b866..e4998f460e11 100644 --- a/packages/firebase_crashlytics/example/android/build.gradle +++ b/packages/firebase_crashlytics/example/android/build.gradle @@ -2,15 +2,12 @@ buildscript { repositories { google() jcenter() - maven { - url 'https://maven.fabric.io/public' - } } dependencies { classpath 'com.android.tools.build:gradle:3.3.2' classpath 'com.google.gms:google-services:4.3.0' - classpath 'io.fabric.tools:gradle:1.26.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta03' } } diff --git a/packages/firebase_crashlytics/example/test_driver/crashlytics.dart b/packages/firebase_crashlytics/example/test_driver/crashlytics.dart index 0169c1e736f4..cee89ed0b75b 100644 --- a/packages/firebase_crashlytics/example/test_driver/crashlytics.dart +++ b/packages/firebase_crashlytics/example/test_driver/crashlytics.dart @@ -17,7 +17,6 @@ void main() { test('recordFlutterError', () async { // This is currently only testing that we can log errors without crashing. final Crashlytics crashlytics = Crashlytics.instance; - await crashlytics.setUserName('testing'); await crashlytics.setUserIdentifier('hello'); crashlytics.setBool('testBool', true); crashlytics.setInt('testInt', 42); diff --git a/packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart b/packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart index 4c95cb4a7081..24b4b6de0a60 100644 --- a/packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart +++ b/packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart @@ -54,21 +54,6 @@ class Crashlytics { throw StateError('Error thrown by Crashlytics plugin'); } - /// Reports the global value for debug mode. - /// TODO(kroikie): Clarify what this means in context of both Android and iOS. - Future isDebuggable() async { - final bool result = - await channel.invokeMethod('Crashlytics#isDebuggable'); - return result; - } - - /// Returns Crashlytics SDK version. - Future getVersion() async { - final String result = - await channel.invokeMethod('Crashlytics#getVersion'); - return result; - } - /// Add text logging that will be sent with your next report. `msg` will be /// printed to the console when in debug mode. Each report has a rolling max /// of 64k of logs, older logs are removed to allow newer logs to fit within @@ -110,13 +95,6 @@ class Crashlytics { _setValue(key, value); } - /// Optionally set a end-user's name or username for display within the - /// Crashlytics UI. Please be mindful of end-user's privacy. - Future setUserEmail(String email) async { - await channel.invokeMethod( - 'Crashlytics#setUserEmail', {'email': email}); - } - /// Specify a user identifier which will be visible in the Crashlytics UI. /// Please be mindful of end-user's privacy. Future setUserIdentifier(String identifier) async { @@ -124,13 +102,6 @@ class Crashlytics { {'identifier': identifier}); } - /// Specify a user name which will be visible in the Crashlytics UI. Please - /// be mindful of end-user's privacy. - Future setUserName(String name) async { - await channel.invokeMethod( - 'Crashlytics#setUserName', {'name': name}); - } - List> _prepareKeys() { final List> crashlyticsKeys = >[]; for (String key in _keys.keys) { diff --git a/packages/firebase_crashlytics/pubspec.yaml b/packages/firebase_crashlytics/pubspec.yaml index e449a0e86835..543cc9ab70e9 100644 --- a/packages/firebase_crashlytics/pubspec.yaml +++ b/packages/firebase_crashlytics/pubspec.yaml @@ -2,7 +2,7 @@ name: firebase_crashlytics description: Flutter plugin for Firebase Crashlytics. It reports uncaught errors to the Firebase console. -version: 0.1.3+3 +version: 0.2.0 homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_crashlytics environment: diff --git a/packages/firebase_crashlytics/test/firebase_crashlytics_e2e.dart b/packages/firebase_crashlytics/test/firebase_crashlytics_e2e.dart index 59f11e023913..b19e37dd6541 100644 --- a/packages/firebase_crashlytics/test/firebase_crashlytics_e2e.dart +++ b/packages/firebase_crashlytics/test/firebase_crashlytics_e2e.dart @@ -1,12 +1,5 @@ -import 'package:flutter_test/flutter_test.dart'; import 'package:e2e/e2e.dart'; -import 'package:firebase_crashlytics/firebase_crashlytics.dart'; void main() { E2EWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('get version', (WidgetTester tester) async { - final String version = await Crashlytics.instance.getVersion(); - expect(version, isNotNull); - }); } diff --git a/packages/firebase_crashlytics/test/firebase_crashlytics_test.dart b/packages/firebase_crashlytics/test/firebase_crashlytics_test.dart index aac0a29dcd82..ef74cffec26b 100644 --- a/packages/firebase_crashlytics/test/firebase_crashlytics_test.dart +++ b/packages/firebase_crashlytics/test/firebase_crashlytics_test.dart @@ -12,7 +12,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - group('$Crashlytics', () { + group('Crashlytics', () { final List log = []; final Crashlytics crashlytics = Crashlytics.instance; @@ -24,14 +24,8 @@ void main() { switch (methodCall.method) { case 'Crashlytics#onError': return 'Error reported to Crashlytics.'; - case 'Crashlytics#isDebuggable': - return true; - case 'Crashlytics#setUserEmail': - return true; case 'Crashlytics#setUserIdentifier': return true; - case 'Crashlytics#setUserName': - return true; case 'Crashlytics#getVersion': return '0.0.0+1'; default: @@ -103,37 +97,10 @@ void main() { expect(log[0].arguments['keys'][3]['type'], 'string'); }); - test('isDebuggable', () async { - expect(await crashlytics.isDebuggable(), true); - expect( - log, - [ - isMethodCall( - 'Crashlytics#isDebuggable', - arguments: null, - ) - ], - ); - }); - test('crash', () { expect(() => crashlytics.crash(), throwsStateError); }); - test('getVersion', () async { - await crashlytics.getVersion(); - expect(log, - [isMethodCall('Crashlytics#getVersion', arguments: null)]); - }); - - test('setUserEmail', () async { - await crashlytics.setUserEmail('foo'); - expect(log, [ - isMethodCall('Crashlytics#setUserEmail', - arguments: {'email': 'foo'}) - ]); - }); - test('setUserIdentifier', () async { await crashlytics.setUserIdentifier('foo'); expect(log, [ @@ -142,14 +109,6 @@ void main() { ]); }); - test('setUserName', () async { - await crashlytics.setUserName('foo'); - expect(log, [ - isMethodCall('Crashlytics#setUserName', - arguments: {'name': 'foo'}) - ]); - }); - test('getStackTraceElements with character index', () async { final List lines = [ 'package:flutter/src/widgets/framework.dart 3825:27 StatefulElement.build'