7

I got the MissingPlugin error. I found quite some posts about the error. But my case is a bit different. First, my project runs fine in simulator, the error only raises when I run my release app on physical Android. Second, this error is not just related to one package. I first got error like MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences) After I put the code I found only to handle the issue with shared_preferences. I then got error like MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/package_info) Obviously the error is not just linked to one package like shared_preferences.

Any idea? how can I solve the problem?

david weng
  • 196
  • 1
  • 1
  • 8
  • Does this answer your question? [Flutter: Unhandled exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared\_preferences)](https://stackoverflow.com/questions/50687801/flutter-unhandled-exception-missingpluginexceptionno-implementation-found-for) – Petrus Nguyễn Thái Học Mar 01 '21 at 07:49
  • Check this answer https://stackoverflow.com/a/71110380/5658233 – Viktar K Feb 14 '22 at 10:31

5 Answers5

4

There's absent super.configureFlutterEngine(flutterEngine) on FlutterActivity.

class MainActivity : FlutterActivity() {    
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine) //missing this
     
    }
}
Michel_T.
  • 2,741
  • 5
  • 21
  • 31
Jack
  • 41
  • 2
3

This is a classic mistake that allot of people make. What you are trying to do is abstract heavy work to an isolate, however flutter isolates cannot run plugins, other than the api in flutter and the dart sdk directly.

You have a couple of options.

  1. There is a plugin I can recommend, it does not support all flutter (3rd party) plugins, but it's worth a try with yours. https://pub.dev/packages/flutter_isolate

This plugin creates isolates that auto marshal plugin work back to the main isolate, without risking a runtime exception that base flutter isolates will normally throw.

  1. Run only the source code of the heavy process, that you are allowed to run in a base flutter isolate, by only using the flutter & dart sdk apis directly. The rest of the code that depends on plugins, will need to be relayed back to the main isolate, and the UI will have to wait for a result using a FutureBuilder
Dan Gerchcovich
  • 168
  • 5
  • 12
  • I don't quite understand this yet. I didn't find another post mentioned solution with isolate. I need read more about the isolate. – david weng Feb 02 '21 at 02:56
  • please take a look at this github issue on the flutter repo. In a nutshell you cannot invoke 3rd party plugin code inside an isolate. (Only in the main isolate). https://github.com/flutter/flutter/issues/13937 – Dan Gerchcovich Feb 02 '21 at 03:43
  • your main isolate is where you run your app, your widgets, your UI, everything that makes your app – Dan Gerchcovich Feb 02 '21 at 03:44
  • I remember now. I think I should not have the isolate issue. I don't have separate isolate when my app loads. Also, how come it works when I use build tool 3.5.1 – david weng Feb 02 '21 at 04:23
  • mmm...you changed the gradle build version? Interesting. Are you using the plugin for generating isolates that I suggested? If so, then they might have made an update and supported this library. As to why only changing the build version fixed this, it sounds like either you are not invoking any plugin api on (non main) isolates or it's something else – Dan Gerchcovich Feb 02 '21 at 04:28
3

Tried a few different solution found online, like clean and rebuild. no-shrink etc. None worked for me.

Finally in the build.gradle, I changed

classpath 'com.android.tools.build:gradle:4.0.0' to classpath 'com.android.tools.build:gradle:3.5.1'

after that, the apk size is 50% of the previous and the app loads fine.

So maybe something with the new build tool.

david weng
  • 196
  • 1
  • 1
  • 8
  • You probably ran into something related to https://github.com/flutter/flutter/issues/58247 and https://github.com/flutter/flutter/pull/71446 – kuhnroyal Feb 03 '21 at 16:16
1

I had a same error on a old flutter app, Running on stable 3.0.2 without null safety. As a result I was using shared_preferences : ^5.4 which worked well in debug, but used to crash the plugin in release mode on Android

Adding

 minifyEnabled false
 shrinkResources false

to android/app/build.gradle fixed the issue

Mahesh Jamdade
  • 17,235
  • 8
  • 110
  • 131
0

have same issue, fixed it by remove reduant plugin directive:

before:

flutter:
  uses-material-design: true
  plugin:
    platforms:
      android:
        package: com.kasem.receive_sharing_intent
        pluginClass: ReceiveSharingIntentPlugin
  assets:
    - assets/i18n/

after:

flutter:
  uses-material-design: true
  assets:
    - assets/i18n/
peakle
  • 149
  • 5