MissingPluginException - is there a fundamental flaw in Flutter's plugin system?

1,958 views
Skip to first unread message

James Allen

unread,
Oct 20, 2020, 5:51:35 AM10/20/20
to Flutter Development (flutter-dev)
Hi there, I just wanted to raise this question as I think it's possibly a major issue which is flying under the radar - I'm hoping to get some input from someone on the Flutter team.

I keep getting MissingPluginException in my app, sometimes during development and sometimes in my live app. The plugin which causes the exception varies (eg I've had it on path_provider, sentry, flutter_secure_storage, flutter_workmanager and others), and it's very hard to reproduce reliably - sometimes a flutter clean or reinstalling the app will solve the problem, sometimes I need to clear the pub cache, it seems to affect some users and not others - the only consistent thing seems to be that it's Android.

After searching around for solutions, I've noticed that there are literally hundreds of issues on Github about this (see for example all these issues), and also tons of posts on this forum, all mention MissingPluginException. In all cases, I have seen no resolution or explanation - either the issues are closed because they are not reproducible, or it's decided it's the fault of another plugin, or the discussion just dies because it's so hard to troubleshoot.

Given the sheer number of issues it makes me think there is a serious, fundamental flaw in how plugin registration works in Flutter, and it's not being picked up because 
a) it's not easily reproducible
b) the issue is scattered across basically all plugins
c) low number of users affected

Is it just me or is there something serious going on here? Would love some input because I'm starting to wonder if I'm going mad or something! Thanks :)

Suzuki Tomohiro

unread,
Oct 20, 2020, 8:03:28 AM10/20/20
to James Allen, Flutter Development (flutter-dev)
Can you share the entire error message?

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/56cac782-609a-4f84-b970-e565a68126a2n%40googlegroups.com.

James Allen

unread,
Oct 20, 2020, 8:24:37 AM10/20/20
to Flutter Development (flutter-dev)
Sure. Here's a bunch that I got just this morning:

I/flutter ( 9767): MissingPluginException(No implementation found for method getLocalTimezone on channel flutter_native_timezone)
I/flutter ( 9767): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
I/flutter ( 9767): #2      FlutterNativeTimezone.getLocalTimezone (package:flutter_native_timezone/flutter_native_timezone.dart:11:34)
I/flutter ( 9767): #3      TimezoneHelper.initialiseTimezone (package:my_flutter_app/helpers/timezone_helper.dart:11:56)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #4      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart:134:28)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #5      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart)
I/flutter ( 9767): #6      TypedMiddleware.call (package:redux/src/utils.dart:229:24)
I/flutter ( 9767):
I/flutter ( 9767): 2020-10-20T13:21:16.750509 E _createInitialiseApp.<ac>.<ac>: Error initialising database 
I/flutter ( 9767): MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
I/flutter ( 9767): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
I/flutter ( 9767): #2      MethodChannelPathProvider.getApplicationDocumentsPath (package:path_provider_platform_interface/src/method_channel_path_provider.dart:50:10)
I/flutter ( 9767): #3      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:104:39)
I/flutter ( 9767): #4      DatabaseProvider.initialiseDatabase (package:my_flutter_app/repository/database_provider.dart:38:42)
I/flutter ( 9767): #5      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart:138:30)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #6      _createInitialiseApp.<anonymous closure> (package:c
I/flutter ( 9767): 2020-10-20T13:21:16.785088 E _createInitialiseApp.<ac>.<ac>: Error initialising revenue cat 
I/flutter ( 9767): MissingPluginException(No implementation found for method setupPurchases on channel purchases_flutter)
I/flutter ( 9767): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
I/flutter ( 9767): #2      Purchases.setup (package:purchases_flutter/purchases_flutter.dart:44:27)
I/flutter ( 9767): #3      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart:145:34)
I/flutter ( 9767): #4      _rootRunUnary (dart:async/zone.dart:1198:47)
I/flutter ( 9767): #5      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
I/flutter ( 9767): #6      _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
I/flutter ( 9767): #7      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
I/flutter ( 9767): #8      Future._propagateToListeners (dart:async/future_impl.dart:725:32)
I/flutter ( 9767): #9      Future._completeError (dart:a
I/flutter ( 9767): 2020-10-20T13:21:16.793962 E _createInitialiseApp.<ac>.<ac>: Error initialising shared prefs 
I/flutter ( 9767): MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
I/flutter ( 9767):
I/flutter ( 9767): 2020-10-20T13:21:16.853791 E main.<ac>: Unhandled exception caught by zone error handler 
I/flutter ( 9767): NoSuchMethodError: The method 'containsKey' was called on null.
I/flutter ( 9767): Receiver: null
I/flutter ( 9767): Tried calling: containsKey("SETTING_TEST_GROUP_ID")
I/flutter ( 9767): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
I/flutter ( 9767): #1      LoadingSaving.getOptionalIntOrDefault (package:my_flutter_app/helpers/shared_preferences_extensions.dart:34:8)
I/flutter ( 9767): #2      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart:157:35)
I/flutter ( 9767): <asynchronous suspension>
I/flutter ( 9767): #3      _createInitialiseApp.<anonymous closure> (package:my_flutter_app/redux/app/app_state_middleware.dart)
I/flutter ( 9767): #4      TypedMiddleware.call (package:redux/src/utils.dart:229:24)
I/flutter ( 9767): #5      Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:255:43)
I/flutter ( 9767): #6      Store.dispatch (package:redux/src/store.dart:267:27)
I/flutter ( 9767): #7      AppLoadingScreen.build.<anonymous closure> (package:my_flutter_app/presentation/app_


Here's one from an issue #71 in flutter_secure_storage:
Unhandled Exception: MissingPluginException(No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage)  


Here's one from an issue  #63 in flutter_workmanager:
MissingPluginException(No implementation found for method initialize on channel be.tramckrijte.workmanager/foreground_channel_work_manager)  


Here's one from flutterfire:

[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method setCurrentScreen on channel plugins.flutter.io/firebase_analytics) #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:7) <asynchronous suspension> #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12) #2 MethodChannelFirebaseAnalytics.setCurrentScreen (package:firebase_analytics_platform_interface/method_channel_firebase_analytics.dart:46:21) #3 FirebaseAnalytics.setCurrentScreen (package:firebase_analytics/firebase_analytics.dart:90:29) #4 FirebaseAnalyticsObserver._sendScreenView (package:firebase_analytics/observer.dart:80:17) #5 FirebaseAnalyticsObserver.didPush (package:firebase_analytics/observer.dart:97:7) 


From path_provider:

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider) #0 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7) <asynchronous suspension> #1 getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:46:22) <asynchronous suspension>


From VideoCompress:

MissingPluginException (MissingPluginException(No implementation found for method getFileThumbnail on channel video_compress))


From firebase_auth:

E/flutter (15385): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method currentUser on channel plugins.flutter.io/firebase_auth) E/flutter (15385): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7) E/flutter (15385): <asynchronous suspension> E/flutter (15385): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12) E/flutter (15385): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:356:48) E/flutter (15385): #3 MethodChannelFirebaseAuth.getCurrentUser (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:43:10) E/flutter (15385): #4 FirebaseAuth.currentUser (package:firebase_auth/src/firebase_auth.dart:316:45)

Suzuki Tomohiro

unread,
Oct 20, 2020, 10:22:19 AM10/20/20
to James Allen, Flutter Development (flutter-dev)
From what I read the error message, I think it’s caused by incompatible version of Flutter framework and library.

Do you use dependency overrides?

Any warning message when you run “flutter pub get”?

James Allen

unread,
Oct 20, 2020, 10:48:53 AM10/20/20
to Flutter Development (flutter-dev)

I don't use dependency overrides, and I don't get any warnings when running flutter pub get.

To be clear, I am not asking for help about a specific instance of an error here. This is a problem that I've encountered on and off over the past year or so, and one that I've experienced with flutter versions 1.17, 1.20 and 1.22, sometimes in dev, sometimes in release, sometimes only on the simulator, and I work around it through various combinations of flutter clean, rebuilding, clearing out flutter cache, reinstalling flutter etc. and hoping that it doesn't occurr too frequently in the wild that I loose too many users to it.

What I'm asking is this: given that there are so many issues where flutter suddenly can't find registered plugins (I mean, if you search for MissingPluginException on github, there are literally hundreds of issues, all basically the same problem, all either unresolved or the problem mysteriously disappears after some combination of flutter clean etc), given that there are so many, could there be a problem with flutter itself? I mean, a problem with how plugins are registered?

Another user, a plugin developer, had the same question here however it got no traction or attention.
Reply all
Reply to author
Forward
0 new messages