MissingPluginException(No implementation found for method check on channel plugins.flutter.io/connectivity

Viewed 2203

I'm using this connectivity plugin to check the internet connectivity status. It works fine with the flutter dart code but when I called the flutter dart code from native android kotlin code this missingplugin exception occurs. So for me this error occurs only when the flutter code is called from native android kotlin code using platform channel.

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method check on channel plugins.flutter.io/connectivity)
E/flutter ( 7294): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
E/flutter ( 7294): <asynchronous suspension>
E/flutter ( 7294): #1      MethodChannelConnectivity.checkConnectivity (package:connectivity_platform_interface/src/method_channel_connectivity.dart:42:10)
E/flutter ( 7294): #2      Connectivity.checkConnectivity (package:connectivity/connectivity.dart:47:22)
E/flutter ( 7294): #3      isConnectivityAvailable (package:kalyan_matrimony/utils/app_utils.dart:872:50)
E/flutter ( 7294): #4      _BasePackageState._callMembershipDetailsApi (package:kalyan_matrimony/screens/payment/base_package.dart:55:16)
E/flutter ( 7294): #5      _BasePackageState.getMembershipDetailsFromAPI (package:kalyan_matrimony/screens/payment/base_package.dart:51:5)
E/flutter ( 7294): <asynchronous suspension>
E/flutter ( 7294): #6      _BasePackageState.initState (package:kalyan_matrimony/screens/payment/base_package.dart:39:5)
E/flutter ( 7294): #7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355:58)
E/flutter ( 7294): #8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201:5)
E/flutter ( 7294): #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194:14)
E/flutter ( 7294): #10     Element.updateChild (package:flutter/src/widgets/framework.dart:2988:12)
E/flutter ( 7294): #11     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5445:14)

Also, The GeneratedPluginRegistrant.java file is called from mainactivity.kt file but in the file there is no registerwith code for connectivity and many other plugins. I don't understand why it is not generated automatically?

package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry;

/**
 * Generated file. Do not edit.
 * This file is generated by the Flutter tool based on the
 * plugins that support the Android platform.
 */
@Keep
public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
    flutterEngine.getPlugins().add(new io.flutter.plugins.camera.CameraPlugin());
    ConnectivityPlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.connectivity.ConnectivityPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.connectivity.ConnectivityPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin());
    flutterEngine.getPlugins().add(new com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin());
      io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin"));
      com.fuyumi.flutterstatusbarcolor.flutterstatusbarcolor.FlutterStatusbarcolorPlugin.registerWith(shimPluginRegistry.registrarFor("com.fuyumi.flutterstatusbarcolor.flutterstatusbarcolor.FlutterStatusbarcolorPlugin"));
      com.aldiferdiyan.xmpp.flutter_xmpp.FlutterXmppPlugin.registerWith(shimPluginRegistry.registrarFor("com.aldiferdiyan.xmpp.flutter_xmpp.FlutterXmppPlugin"));
      com.aloisdeniel.geocoder.GeocoderPlugin.registerWith(shimPluginRegistry.registrarFor("com.aloisdeniel.geocoder.GeocoderPlugin"));
    flutterEngine.getPlugins().add(new vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.inapppurchase.InAppPurchasePlugin());
    flutterEngine.getPlugins().add(new com.lyokone.location.LocationPlugin());
      com.baseflow.location_permissions.LocationPermissionsPlugin.registerWith(shimPluginRegistry.registrarFor("com.baseflow.location_permissions.LocationPermissionsPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.packageinfo.PackageInfoPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
    flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
      com.danieldallos.storeredirect.StoreRedirectPlugin.registerWith(shimPluginRegistry.registrarFor("com.danieldallos.storeredirect.StoreRedirectPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.webviewflutter.WebViewFlutterPlugin());
  }
}

Any suggestions would be really helpful. Thanks in advance.

1 Answers

The connectivity plugin doesn't seem to require writing any platform-specific code. Have you tried running a restart after adding the plugin? A hot reload may have yet to include the plugin that you've added.

If you're still having issues, it's best to share a minimal repro for us to be able to better understand the issue.

Related