Eishon
Eishon

Reputation: 1324

Missing plugin exception in Flutter while implementing platform specific code

While implementing platform specific code for Android I faced the following error.

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)

Upvotes: 0

Views: 812

Answers (1)

Eishon
Eishon

Reputation: 1324

I faced this issue while implementing platform specific code. I want to share my experience in this case.

First clean the project using

flutter clean

Then upgrade the plugins using

flutter pub get

Then run project(Not hot reload. Plugins will inject codes)

flutter run

If the problem persist again, you may be missing

GeneratedPluginRegistrant.registerWith(flutterEngine)

which you have to place here

override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
    //***HERE***
    GeneratedPluginRegistrant.registerWith(flutterEngine)
    MethodChannel(flutterEngine.dartExecutor.binaryMessenger, BEACON_ACTIVATE_CHANNEL).setMethodCallHandler{
        call, result ->
        when {
            call.method.equals("yourMethodName") -> {
                yourNativeFunction(call, result)
            }
        }
    }
}

Upvotes: 1

Related Questions