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

7cwmlq89  于 2023-04-21  发布在  其他
关注(0)|答案(3)|浏览(219)

尝试在模拟器上运行我的应用程序,但不断收到此错误:
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):重新声明: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):重新声明: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):无法访问“”:it is private in 'VideoCompressPlugin'在'VideoCompressPlugin'中是私有的: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):没有为参数'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):没有为参数“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):没有为参数“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):未解析引用:初始化
失败:生成失败,出现异常。

  • 出了什么问题:任务“:video_compress:compileDebugKotlin”执行失败。

编译错误。有关详细信息,请参阅日志

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

  • 运行Flutter医生没有问题。
  • 更改视频压缩依赖关系的向下和向上版本不变(video_compress:^2.1.0)
  • 更新flutter至最新版本(当前为51.0.2)
  • 添加flutter_svg:^0.18.0到pubspec
  • Flutter清洁
  • 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: []);

另一种可能:

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;
  }

会非常感谢任何指导。
汤姆

qv7cva1a

qv7cva1a1#

尝试添加这个软件包flutter_svg: ^0.18.0到pubsec.yaml中,然后再试一次。
并尝试这些步骤https://nabil6391.medium.com/solutions-to-flutter-error-gradle-task-assembledebug-failed-with-exit-code-1-1d2c36b2001a

mdfafbf1

mdfafbf12#

对我来说,答案是我的主.dart文件由于各种原因在lib文件夹之外。我把它移回了lib文件夹。
除此之外,我从Android Studio项目选项卡中删除了gradle文件,然后重新构建。我还文件〉无效缓存。现在似乎可以做到这一点。

cczfrluj

cczfrluj3#

我想您在更新到 video_compressv2.1.0时,缓存的版本号是v2.0.0,所以日志中出现了 “Redeclaration” 错误,您可以在终端中运行:
flutter clean && flutter packages get

相关问题