未处理的异常:MissingPluginException(未找到实现

时间:2020-01-05 13:54:49

标签: android flutter dart

我在多个插件中有问题

image_picker:^ 0.6.2 + 3,位置:^ 2.3.5,...

我确实做得很干净,但没有任何改变

Android设备: SM-N900

Android版本: 5.0

MainActivity

import androidx.annotation.NonNull;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
  @Override
  public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);
  }
} 

GeneratedPluginRegistrant

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.deviceinfo.DeviceInfoPlugin());
      io.flutter.plugins.imagepicker.ImagePickerPlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.imagepicker.ImagePickerPlugin"));
      com.lyokone.location.LocationPlugin.registerWith(shimPluginRegistry.registrarFor("com.lyokone.location.LocationPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
      flutter.plugins.screen.screen.ScreenPlugin.registerWith(shimPluginRegistry.registrarFor("flutter.plugins.screen.screen.ScreenPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
      com.tekartik.sqflite.SqflitePlugin.registerWith(shimPluginRegistry.registrarFor("com.tekartik.sqflite.SqflitePlugin"));
      altercode.xyz.uniqueidentifier.UniqueIdentifierPlugin.registerWith(shimPluginRegistry.registrarFor("altercode.xyz.uniqueidentifier.UniqueIdentifierPlugin"));
    flutterEngine.getPlugins().add(new io.flutter.plugins.urllauncher.UrlLauncherPlugin());
  }
}

颤抖的医生

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
 Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version
    6.1.7601], locale en-US)
 Android toolchain - develop for Android devices (Android SDK version 28.0.
3)
 Android Studio (version 3.5)
[!] IntelliJ IDEA Community Edition (version 2018.3)
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.38.1)
    X Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.

我的例外之一是:

E / flutter(8362):[错误:flutter / lib / ui / ui_dart_state.cc(157)]未处理的异常:MissingPluginException(在方法lyokone / location上未找到方法serviceEnabled的实现) E / flutter(8362):#0 MethodChannel.invokeMethod(软件包:flutter / src / services / platform_channel.dart:319:7) E /颤振(8362): E / flutter(8362):#1 Location.serviceEnabled(package:location / location.dart:74:16) E / flutter(8362):#2 _SettingState._wifiStatus(package:flutter_example / Setting.dart:231:49) E / flutter(8362):#3 _InkResponseState._handleTap(包:flutter / src / material / ink_well.dart:706:14) E / flutter(8362):#4 _InkResponseState.build。 (包装:flutter / src / material / ink_well.dart:789:36) E / flutter(8362):#5 GestureRecognizer.invokeCallback(package:flutter / src / gestures / recognizer.dart:182:24) E / flutter(8362):#6 TapGestureRecognizer.handleTapUp(包:flutter / src / gestures / tap.dart:486:11) E / flutter(8362):#7 BaseTapGestureRecognizer._checkUp(包:flutter / src / gestures / tap.dart:264:5) E / flutter(8362):#8 BaseTapGestureRecognizer.handlePrimaryPointer(包:flutter / src / gestures / tap.dart:199:7) E / flutter(8362):#9 PrimaryPointerGestureRecognizer.handleEvent(package:flutter / src / gestures / recognizer.dart:467:9) E / flutter(8362):#10 PointerRouter._dispatch(软件包:flutter / src / gestures / pointer_router.dart:76:12) E / flutter(8362):#11 PointerRouter._dispatchEventToRoutes。 (软件包:flutter / src / gestures / pointer_router.dart:117:9) E / flutter(8362):#12 _LinkedHashMapMixin.forEach(dart:collection-patch / compact_hash.dart:379:8) E / flutter(8362):#13 PointerRouter._dispatchEventToRoutes(package:flutter / src / gestures / pointer_router.dart:115:18) E / flutter(8362):#14 PointerRouter.route(软件包:flutter / src / gestures / pointer_router.dart:101:7) E / flutter(8362):#15 GestureBinding.handleEvent(package:flutter / src / gestures / binding.dart:218:19) E / flutter(8362):#16 GestureBinding.dispatchEvent(package:flutter / src / gestures / binding.dart:198:22) E / flutter(8362):#17 GestureBinding._handlePointerEvent(package:flutter / src / gestures / binding.dart:156:7) E / flutter(8362):#18 GestureBinding._flushPointerEventQueue(package:flutter / src / gestures / binding.dart:102:7) E / flutter(8362):#19 GestureBinding._handlePointerDataPacket(package:flutter / src / gestures / binding.dart:86:7) E / flutter(8362):#20 _rootRunUnary(dart:async / zone.dart:1138:13) E / flutter(8362):#21 _CustomZone.runUnary(dart:async / zone.dart:1031:19) E / flutter(8362):#22 _CustomZone.runUnaryGuarded(dart:async / zone.dart:933:7) E / flutter(8362):#23 _invoke1(dart:ui / hooks.dart:273:10) E / flutter(8362):#24 _dispatchPointerDataPacket(dart:ui / hooks.dart:182:5)

还有我的代码:

var _locationService = new Location();

bool serviceStatus = await _locationService.serviceEnabled();

1 个答案:

答案 0 :(得分:1)

您是否尝试在添加插件后重新启动?使用 hot reload 运行应用程序可能尚未包含您最近添加到构建中的插件。