Search code examples
androidfluttervideo-player

Cannot find symbol import io.flutter.FlutterInjector


I am trying to play video from url. I am using video_player package. But when I try to run the project the build fails with the error message as below:

    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

Solution

  • First of all check your flutter channel to see if this package supports this channel or not. Make sure you are in stable channel. Second, update package to it's lastest version. Third, do the flutter clean, typing in terminal(better not to use android studio tools)