找不到符号导入 io.flutter.FlutterInjector

Cannot find symbol import io.flutter.FlutterInjector

我正在尝试播放来自 url 的视频。我正在使用 video_player 包。但是当我尝试 运行 项目时,构建失败并显示如下错误消息:

    C:\flutter\.pub-cache\hosted\pub.dartlang.org\video_player-1.0.1\android\src\main\java\io\flutter\plugins\videoplayer\VideoPlayerPlugin.java:10: error: cannot find symbol
import io.flutter.FlutterInjector;
                 ^
  symbol:   class FlutterInjector
  location: package io.flutter
C:\flutter\.pub-cache\hosted\pub.dartlang.org\video_player-1.0.1\android\src\main\java\io\flutter\plugins\videoplayer\VideoPlayerPlugin.java:77: error: cannot find symbol
    final FlutterInjector injector = FlutterInjector.instance();
          ^
  symbol:   class FlutterInjector
  location: class VideoPlayerPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\video_player-1.0.1\android\src\main\java\io\flutter\plugins\videoplayer\VideoPlayerPlugin.java:77: error: cannot find symbol
    final FlutterInjector injector = FlutterInjector.instance();
                                     ^
  symbol:   variable FlutterInjector
  location: class VideoPlayerPlugin
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':video_player:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

首先检查你的flutter频道,看看这个包是否支持这个频道。确保您处于稳定的频道中。 其次,将包更新到最新版本。 第三,清除 flutter,在终端中输入(最好不要使用 android studio 工具)