Flutter 如何解决:Gradle任务assembleDebug失败,退出代码1错误?用于视频压缩

Flutter 如何解决:Gradle任务assembleDebug失败,退出代码1错误?用于视频压缩,flutter,gradle,build,Flutter,Gradle,Build,试图在emulator上运行我的应用程序,但不断出现以下错误: e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.0.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(25,7):重新声明:VideoCompressPlugin e:C:\flatter.pub cache\hosted\pub.dartla

试图在emulator上运行我的应用程序,但不断出现以下错误:

e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.0.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(25,7):重新声明:VideoCompressPlugin e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(28,7):重新声明:VideoCompressPlugin e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(184,28):无法访问“”:它在“VideoCompressPlugin”中是私有的 e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(184,48):没有为参数“活动”传递值 e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(184,48):没有为参数“context”传递值 e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(184,48):没有为参数“channel”传递值 e:C:\flatter.pub cache\hosted\pub.dartlang.org\video\u compress-2.1.0\android\src\main\kotlin\com\example\video\u compress\VideoCompressPlugin.kt:(185,22):未解析的引用:init

失败:生成失败,出现异常

  • 出了什么问题: 任务“:视频压缩:CompiledBugkotlin”的执行失败
编译错误。有关更多详细信息,请参阅日志

到目前为止我所尝试的:

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

    return info;
  }
  • 运行颤振医生没有问题
  • 更改视频压缩依赖项的上下版本无更改(视频压缩:^2.1.0)
  • 将颤振更新至最新版本(当前为51.0.2)
  • 将颤振svg:^0.18.0添加到pubspec
  • 扑通
  • 在Android Studio中使缓存无效
可能的罪犯?

_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: []);
\u submit()异步{
if(videoList.isEmpty | | outputPath.isEmpty)返回;
如果(!isLoading){
设置状态(){
isLoading=true;
});
}
打印('LOG:outputPath:$outputPath');
var outPutFileExists=等待文件(outputPath).exists();
打印('LOG:output file exists$outPutFileExists');
videoUrl=wait-StorageService.uploadVideo(文件(outputPath));
imageUrl=wait-StorageService.uploadvideo缩略图(文件(outputPath));
职位(
imageUrl:imageUrl,
videoUrl:videoUrl,
likeCount:0,
authorId:Provider.of(context).currentUserId,
timestamp:timestamp.fromDate(DateTime.now()),
浏览次数:0,
模式:“初学者”,
cardId:widget.card.card[0],
类别:widget.card.category,
标记为:false,
旗帜:[]);
另一种可能性:

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

    return info;
  }
静态未来压缩视频(文件)异步{
最终信息=等待视频压缩。压缩视频(
file.path,
质量:视频质量,最高质量,
deleteOrigin:false,
);
退货信息;
}
第三次尝试:

    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;
  }
静态未来上传视频(文件视频文件)异步{
字符串videoId=Uuid().v4();
MediaInfo videoInfo=等待压缩视频(视频文件);
StorageUploadTask上传任务=
storageRef.child('videos/videoId.mp4').putFile(videoInfo.file);
StorageTaskSnapshot storageSnap=等待上载Task.onComplete;
String downloadUrl=await-storageSnap.ref.getDownloadURL();
返回下载URL;
}
静态未来上传视频缩略图(文件视频文件)异步{
字符串photoId=Uuid().v4();
final thumbnailFile=wait VideoCompress.getFileThumbnail(videoFile.path,
质量:100,//默认值(100)
位置:-1//默认值(-1)
);
StorageUploadTask uploadTask=storageRef
.child('images/thumbnails/image_$photoId.jpg'))
.putFile(thumbnailFile);
StorageTaskSnapshot storageSnap=等待上载Task.onComplete;
String downloadUrl=await-storageSnap.ref.getDownloadURL();
返回下载URL;
}
非常感谢您的指导


Tom

尝试在pubsec.yaml中添加此包
flatter\u svg:^0.18.0
,然后重试

并尝试这些给定的步骤

对我来说,答案是由于各种原因,我的主.dart文件不在lib文件夹中。我将其移回lib


除此之外,我还从Android Studio项目选项卡中删除了gradle文件,然后重新生成。我还创建了文件>无效缓存。目前看来这是个好办法。

嘿,通过查看您的错误消息,它发现您的方法频道有问题,您提供的任何信息都不够,请提供您的mainActivit定义通道的y代码以及相对颤振代码Hey Atul,MainActivity文件中没有太多信息。您是否需要查看整个页面代码以查看错误所在?您是否使用方法通道访问某些平台特定功能???。如果是,则共享与主活动和颤振代码f相关的所有代码您访问方法通道的rom Hey Atul,请参见上文。希望能有所帮助。Hey Mohammad,感谢您在pubspec:(@nerdMonkey)中添加flatter_svg:^0.18.0时未做任何更改。尝试另一个视频压缩包是更好的选择