sidlatau / flutter_email_sender

Allows send emails from flutter using native platform functionality.
Apache License 2.0
151 stars 84 forks source link

Missing Android v2 embedding causes a crash #68

Closed sergey-triputsco closed 3 years ago

sergey-triputsco commented 3 years ago

Latest flutter plugin guidelines suggest to switch Android V2 embedding API. For migration steps see https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration

When an application declares V2 embedding then plugin is added in backward compatibility mode and actually works in UI mode when Activity instance exists. But plugin causes a crash when app runs in background and performs regular plugins registration via calling: io.flutter.plugins.GeneratedPluginRegistrant.registerWith

Then flutter_email_sender crashes:

E/AndroidRuntime( 2027): Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
E/AndroidRuntime( 2027):    at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:119)
E/AndroidRuntime( 2027):    at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin$Companion.registerWith(FlutterEmailSenderPlugin.kt:35)
E/AndroidRuntime( 2027):    at com.sidlatau.flutteremailsender.FlutterEmailSenderPlugin.registerWith(Unknown Source:2)
E/AndroidRuntime( 2027):    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:31)

Proper implementation of Android V2 embedding solves the issue

spkersten commented 3 years ago

@sidlatau I see you fixed this in master. Could you release a new version to pub.dev with this fix?

sidlatau commented 3 years ago

Sorry for the delay, just published v5.0.1