如何解决:Gradle task assembleDebug failed with exit code 1 error?用于视频压缩

How does one resolve: Gradle task assembleDebug failed with exit code 1 error? for video compress

尝试在模拟器上 运行 我的应用程序,但不断收到此错误:

e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.0.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (25, 7): Redeclaration: VideoCompressPlugin e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (28, 7): Redeclaration: VideoCompressPlugin e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (184, 28): Cannot access '': it is private in 'VideoCompressPlugin' e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (184, 48): No value passed for parameter 'activity' e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (184, 48): No value passed for parameter 'context' e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (184, 48): No value passed for parameter 'channel' e: C:\flutter.pub-cache\hosted\pub.dartlang.org\video_compress-2.1.0\android\src\main\kotlin\com\example\video_compress\VideoCompressPlugin.kt: (185, 22): Unresolved reference: init

失败:构建失败,出现异常。

Compilation error. See log for more details

到目前为止我已经尝试过:

可能违规?

_submit() async {
if (videoList.isEmpty || outputPath.isEmpty) return;

if (!isLoading) {
  setState(() {
    isLoading = true;
  });
}
print('LOG: outputPath: $outputPath');
var outPutFileExists = await File(outputPath).exists();
print('LOG: output file exists $outPutFileExists');

videoUrl = await StorageService.uploadVideo(File(outputPath));
imageUrl = await StorageService.uploadVideoThumbnail(File(outputPath));

Post post = Post(
    imageUrl: imageUrl,
    videoUrl: videoUrl,
    likeCount: 0,
    authorId: Provider.of<UserData>(context).currentUserId,
    timestamp: Timestamp.fromDate(DateTime.now()),
    viewCount: 0,
    mode: 'Beginner',
    cardId: widget.card.card[0],
    category: widget.card.category,
    flagged: false,
    flags: []);

另一种可能:

 static Future<MediaInfo> compressVideo(File file) async {
    final info = await VideoCompress.compressVideo(
      file.path,
      quality: VideoQuality.HighestQuality,
      deleteOrigin: false,
    );

    return info;
  }

第三次尝试:

    static Future<String> uploadVideo(File videoFile) async {
    String videoId = Uuid().v4();
    MediaInfo videoInfo = await compressVideo(videoFile);
    StorageUploadTask uploadTask =
        storageRef.child('videos/video_$videoId.mp4').putFile(videoInfo.file);

    StorageTaskSnapshot storageSnap = await uploadTask.onComplete;
    String downloadUrl = await storageSnap.ref.getDownloadURL();
    return downloadUrl;
  }

  static Future<String> uploadVideoThumbnail(File videoFile) async {
    String photoId = Uuid().v4();
    final thumbnailFile = await VideoCompress.getFileThumbnail(videoFile.path,
        quality: 100, // default(100)
        position: -1 // default(-1)
        );
    StorageUploadTask uploadTask = storageRef
        .child('images/thumbnails/image_$photoId.jpg')
        .putFile(thumbnailFile);
    StorageTaskSnapshot storageSnap = await uploadTask.onComplete;
    String downloadUrl = await storageSnap.ref.getDownloadURL();
    return downloadUrl;
  }

非常感谢任何指导。

汤姆

尝试在 pubsec.yaml 中添加此包 flutter_svg: ^0.18.0,然后重试。

并尝试这些给定的步骤 https://nabil6391.medium.com/solutions-to-flutter-error-gradle-task-assembledebug-failed-with-exit-code-1-1d2c36b2001a

对我来说,答案是我的 main.dart 文件出于各种原因位于 lib 文件夹之外。我把它移回了 lib。

除此之外,我从 Android Studio 项目选项卡中删除了 gradle 文件,然后重新构建。我还文件 > 无效的缓存。现在似乎可以解决问题。