mingchen / ios_app_group

A Flutter plugin to access shared application group container on iOS.
https://pub.dev/packages/ios_app_group
BSD 2-Clause "Simplified" License
2 stars 14 forks source link

Registration plugin on Android causes a crash #2

Open sergey-triputsco opened 3 years ago

sergey-triputsco commented 3 years ago

Plugin crashes when registering plugins via calling GeneratedPluginRegistrant.registerWith(flutterEngine). Registration of plugins is performed when app runs in background e.g. Service handle some platform Intent and starts headless FlutterEngine that executes some dart code.

E/AndroidRuntime(23578): 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(23578):    at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:119)
E/AndroidRuntime(23578):    at com.github.mingchen.flutter.plugins.ios_app_group.IosAppGroupPlugin.registerWith(IosAppGroupPlugin.java:14)

ios_app_group plugin uses Android v1 embedding api. Our app already has been migrated to use v2 Android embedding.

<meta-data
      android:name="flutterEmbedding"
      android:value="2" />

Problem disappear if plugin migrated to android v2 embedding. All migration steps are described here https://flutter.dev/docs/development/packages-and-plugins/plugin-api-migration

sergey-triputsco commented 3 years ago

Plugin migration PR #3 With that changes plugin doesn't crash on Android on registration.