Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agconnect_crash/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.9.1+301

- Removed deprecated Android v1 embedding (`PluginRegistry.Registrar`) for Flutter 3.29+ compatibility.
- Made `recordError` accept nullable `StackTrace` with fallback to `StackTrace.current`.

## 1.9.0+300

- **[Breaking Changes]**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;

public class AGConnectCrashPlugin implements FlutterPlugin, MethodCallHandler {
private MethodChannel channel;
Expand All @@ -45,12 +44,6 @@ public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBindin
channel.setMethodCallHandler(this);
}

public static void registerWith(Registrar registrar) {
initAGConnectSDK(registrar.context().getApplicationContext());
final MethodChannel channel = new MethodChannel(registrar.messenger(), "com.huawei.flutter/agconnect_crash");
channel.setMethodCallHandler(new AGConnectCrashPlugin());
}

static void initAGConnectSDK(Context context) {
if (AGConnectInstance.getInstance() == null) {
AGConnectInstance.initialize(context);
Expand Down
10 changes: 7 additions & 3 deletions agconnect_crash/lib/src/agconnect_crash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AGCCrash {
/// ```
Future<void> onFlutterError(FlutterErrorDetails details) async {
FlutterError.dumpErrorToConsole(details, forceReport: true);
recordError(details.exceptionAsString(), details.stack!);
await recordError(details.exception, details.stack);
}

///Call the onFlutterError and recordError methods in the main function to
Expand All @@ -75,8 +75,12 @@ class AGCCrash {
/// AGCCrash.instance.recordError(error, stackTrace, true);
///}
/// ```
Future<void> recordError(dynamic exception, StackTrace stack,
{bool fatal = false}) async {
Future<void> recordError(
dynamic exception,
StackTrace? stack, {
bool fatal = false,
}) async {
stack ??= StackTrace.current;
debugPrint(
'Error caught by AGCCrash : ${exception.toString()} \n${stack.toString()}');
await _channel.invokeMethod('recordError', <String, String>{
Expand Down
2 changes: 1 addition & 1 deletion agconnect_crash/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: agconnect_crash
description: Flutter plugin for AppGallery Connect Crash SDK.
version: 1.9.0+300
version: 1.9.1+301
homepage: https://developer.huawei.com/consumer/cn/doc/development/AppGallery-connect-Guides/agc-crash-introduction

environment:
Expand Down