Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Trying to run my app on the emulator but keep getting this error:

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

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':video_compress:compileDebugKotlin'.

Compilation error. See log for more details

What I have tried so far:

  • running Flutter doctor no issues.
  • Changing down and up versions of the video compress dependency no change (video_compress: ^2.1.0)
  • Update flutter to latest version (currently 51.0.2)
  • Adding flutter_svg: ^0.18.0 to the pubspec
  • Flutter clean
  • Invalidate caches in Android Studio

A possible offender?

_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: []);

Another possibility:

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

    return info;
  }

Third try:

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

Would be very grateful for any guidance.

Tom

like image 813
nerdMonkey Avatar asked Oct 15 '25 17:10

nerdMonkey


1 Answers

I think when you were updating to video_compress v2.1.0, you still had version v2.0.0 cached. Thus, the "Redeclaration" error in the log. You might want to run this in your terminal:

flutter clean && flutter packages get

like image 122
Giraldi Avatar answered Oct 17 '25 08:10

Giraldi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!