Build failed in Flutter app due to video_compress package

984 Views Asked by At

I have been working an a flutter project that requires to upload video and thumbnail. I used flutter video_compress package to compress the video and get a thumbnail. After Adding video_compress package to pubspec.yaml file i found this error.


* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.otaliastudios:transcoder:0.9.1.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
       - https://repo.maven.apache.org/maven2/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
       - https://storage.googleapis.com/download.flutter.io/com/otaliastudios/transcoder/0.9.1/transcoder-0.9.1.pom
     Required by:
         project :app > project :video_compress

* 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 25s
Exception: Gradle task assembleDebug failed with exit code 1

I tried flutter clean and flutter pub get command but build results same error.

My code in video Controller is.


  _compressVideo(String videoPath) async {
    final compressedVideo = await VideoCompress.compressVideo(
      videoPath,
      quality: VideoQuality.MediumQuality,
    );

    return compressedVideo!.file;
  }

  _getThumbnail(String videoPath) async {
    final thumbnail = await VideoCompress.getFileThumbnail(videoPath);
    return thumbnail;
  }

2

There are 2 best solutions below

0
On

Use video_compress_plus instead and make sure to set the minSdkVersion to 21 in the app level build.gradle on this path: .\android\app\build.gradle

0
On

if you are facing the build failed error while using video_compress, then you can solve this problem by using the below maven link in build.gradle:

   maven { url "https://plugins.gradle.org/m2/" }

the overal gradle look like this:

allprojects {
repositories {
    google()
    mavenCentral()
    maven { url "https://plugins.gradle.org/m2/" }

} }

it worked for me and it should worked for you too. Upvote if this tricks works.