Skip to content

MissingPluginException #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johannphilippe opened this issue Feb 10, 2022 · 4 comments
Closed

MissingPluginException #222

johannphilippe opened this issue Feb 10, 2022 · 4 comments

Comments

@johannphilippe
Copy link

Weird issue here. My app was working fine, using the flutter-pi version that uses flutter 2.8. I rebuilt it after changing just one small thing (not related at all to the bug). Then after uploading it to the raspberry, I get the following error when I use the getApplicationDocumentsDirectory from path_provider.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] 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:175)
<asynchronous suspension>
#1      getApplicationDocumentsDirectory (package:path_provider/path_provider.dart:115)
<asynchronous suspension>
#2      _MyHomePageState.build.<anonymous closure> (package:flutter_csound/main.dart:598)
<asynchronous suspension>

Though, all other packages and plugins are working fine here. Just this one seems to miss. I tried a few things, rebuild with the last version (target flutter 2.10, dart 2.16), and this bug remains.
Any idea ?

@johannphilippe
Copy link
Author

Also, I should mention that getApplicationDocumentsDirectory works fine if I don't run it with --release.

@ardera
Copy link
Owner

ardera commented Feb 10, 2022

Three ways to fix it:

  1. pin path_provider to version 2.0.7 or older
  2. do PathProviderPlatform.instance = PathProviderLinux(); as the first line inside your apps main
  3. build a native app from your flutter app, for example: flutter build linux. Then, build the asset bundle using flutter build bundle --target=.dart_tool/flutter_build/generated_main.dart instead of the simple flutter build bundle in the readme

There were some changes in the SDK that affected the autoregistration of plugin platform implementations. Previously, plugins had to manually find out what platform they're running on (windows, linux) and use the right implementation for that platform. Since flutter 2.5, the flutter SDK will generate some code that'll automatically register the correct platform implementation. (That's what .dart_tool/flutter_build/generated_main.dart does). path_provider since version 2.0.8 will completely rely on that new way to register plugin platform implementations. However, flutter build bundle won't generate nor compile that generated_main.dart file by default, so you have to generate it yourself (by building for a platform that will generate it) and explictly tell flutter build bundle to compile it. If you don't, path_provider will use a default implementation, which won't work on flutter-pi

There's some PRs on the flutter SDK that might address this, but they're still in review

@eximius313
Copy link

There's some PRs on the flutter SDK that might address this, but they're still in review

Could you please post a link to this PR?

@ardera
Copy link
Owner

ardera commented Aug 19, 2022

@eximius313 sure, here: flutter/flutter#90958

It's my PR but I let it slide a bit. Hope I get to it this or next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants