-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
flutter/packages
#7498Labels
r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to reproduce
App Crashes while building
Expected results
App Run
Actual results
App Crash
Code sample
Code sample
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:video_player/video_player.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int progress = 0;
late VideoPlayerController _controller;
String videoUrl =
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ForBiggerMeltdowns.mp4";
@override
void initState() {
super.initState();
_controller = VideoPlayerController.networkUrl(Uri.parse(videoUrl))
..initialize().then((_) {
setState(() {});
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
Future<void> downloadVideo(String url, String fileName) async {
try {
// Request storage permission
var status = await Permission.storage.request();
if (status.isGranted) {
// Get the directory to save the file
Directory? appDocDir = await getExternalStorageDirectory();
String savePath = "${appDocDir?.path}/$fileName";
// Create an instance of Dio
Dio dio = Dio();
// Start the download
await dio.download(
url,
savePath,
onReceiveProgress: (received, total) {
if (total != -1) {
setState(() {
progress = ((received / total) * 100).toInt();
});
}
},
);
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
backgroundColor: Colors.green,
content: Text(
"Video downloaded successfully!",
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
);
} else {
print("Permission denied!");
}
} catch (e) {
print("Error downloading video: $e");
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: const Text('Video Downloader'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: const Center(
child: CircularProgressIndicator.adaptive(),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () async {
await downloadVideo(videoUrl, videoUrl.split("/").last);
},
child: const Text("Download Video"),
),
const SizedBox(height: 20),
if (progress > 0)
Text(
"Download Progress: $progress%",
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
size: 30,
color: Colors.white,
),
),
),
);
}
}
Logs
Logs
C:\Users\muhammad\AppData\Local\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
C:\Users\muhammad\AppData\Local\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 11s
Error: Gradle task assembleDebug failed with exit code 1Flutter Doctor output
Doctor output
[√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.22631.4037], locale en-US)
• Flutter version 3.22.3 on channel stable at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b0850beeb2 (5 weeks ago), 2024-07-16 21:43:41 -0700
• Engine revision 235db911ba
• Dart version 3.4.4
• DevTools version 2.34.3
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\muhammad\AppData\Local\Android\sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.8.34330.188
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2024.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.11+0--11852314)
[√] VS Code, 64-bit edition (version 1.92.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.94.0
[√] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4037]
• Edge (web) • edge • web-javascript • Microsoft Edge 127.0.2651.105
[√] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
Hassan6197, noforeignland, HyunJoonS, ApuPradhan, gitkrishraj and 1 more
Metadata
Metadata
Assignees
Labels
r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version