Skip to content

Build Failure due to Missing SurfaceProducer.Callback in video_player_android Plugin #154054

@louisvassout

Description

@louisvassout

Steps to reproduce

1.	Create a new Flutter project or use an existing project that includes the video_player plugin.
2.	Run flutter pub get to ensure all dependencies are fetched.
3.	Attempt to build the project using flutter build apk --debug.

Expected results

The project should build successfully without any errors.

Actual results

.../.pub-cache/hosted/pub.dev/video_player_android-2.7.0/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java:22: error: cannot find symbol
final class VideoPlayer implements TextureRegistry.SurfaceProducer.Callback {
                                                                  ^
  symbol:   class Callback
  location: interface SurfaceProducer
/Users/didiervassout/.pub-cache/hosted/pub.dev/video_player_android-2.7.0/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java:84: error: cannot find symbol
    surfaceProducer.setCallback(this);
                   ^
  symbol:   method setCallback(VideoPlayer)
  location: variable surfaceProducer of type SurfaceProducer

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: VideoPlayerScreen(),
    );
  }
}

class VideoPlayerScreen extends StatefulWidget {
  @override
  _VideoPlayerScreenState createState() => _VideoPlayerScreenState();
}

class _VideoPlayerScreenState extends State<VideoPlayerScreen> {
  late VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
      'https://www.example.com/video.mp4',
    )..initialize().then((_) {
        setState(() {});
      });
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _controller.value.isInitialized
            ? AspectRatio(
                aspectRatio: _controller.value.aspectRatio,
                child: VideoPlayer(_controller),
              )
            : CircularProgressIndicator(),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
/Users/didiervassout/.pub-cache/hosted/pub.dev/video_player_android-2.7.0/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java:22: error: cannot find symbol
final class VideoPlayer implements TextureRegistry.SurfaceProducer.Callback {
                                                                  ^
  symbol:   class Callback
  location: interface SurfaceProducer
/Users/didiervassout/.pub-cache/hosted/pub.dev/video_player_android-2.7.0/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayer.java:84: error: cannot find symbol
    surfaceProducer.setCallback(this);
                   ^
  symbol:   method setCallback(VideoPlayer)
  location: variable surfaceProducer of type SurfaceProducer
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':video_player_android: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

BUILD FAILED in 13s

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.6.1 23G93 darwin-arm64, locale fr-FR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.92.2)
[✓] Connected device (4 available)
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions