'Flutter - Build failed with an exception

When I launched my app, I got this error message. I did not make any changes since last run, when everything was fine. Does anybody know how to solve this? Thank you.

FAILURE: Build failed with an exception.
  • What went wrong: Could not determine the dependencies of task ':app:processDebugResources'.

Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. Could not resolve io.grpc:grpc-core:[1.28.0]. Required by: project :app > project :cloud_firestore > com.google.firebase:firebase-firestore:22.1.2 > io.grpc:grpc-android:1.28.0 project :app > project :cloud_firestore > com.google.firebase:firebase-firestore:22.1.2 > io.grpc:grpc-okhttp:1.28.0 > Failed to list versions for io.grpc:grpc-core. > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/io/grpc/grpc-core/maven-metadata.xml. > Could not get resource 'https://google.bintray.com/exoplayer/io/grpc/grpc-core/maven-metadata.xml'. > Could not GET 'https://google.bintray.com/exoplayer/io/grpc/grpc-core/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

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



Solution 1:[1]

The solution I founded was upgrade all my packages.

flutter pub upgrade --major-versions

After treat all the issues and problems.

Upgrade the kotlin version too.

from ext.kotlin_version = '1.3.50' to ext.kotlin_version = '1.4.32'

Or the latest Kotlin version.

Try to run your project again.

Solution 2:[2]

Basic problem that version of io.grpc:grpc-core:[1.28.0] is not specified strictly and gradle have to find possible versions but google.bintray.com is down - no version listing available

  1. Find what version is - this [1.28.0] mean it has versions range Gradle Declaring Versions and Ranges

  2. The [ and ] symbols indicate an inclusive bound with only one version - so consider take exactly 1.28.0

  3. Constrain your transitive dependency with maximum possible version 1.28.0

Edit your project app/build.gradle:

dependencies {
  ...
  constraints {
    implementation('io.grpc:grpc-core') {
        version {
            strictly '1.28.0'
        }
    }
  }
}

Solution 3:[3]

Follow these three steps

1. flutter pub cache repair.

2. flutter Clean.

Finally and the most important

3. Modify the build.gradle file as below change jcenter() to mavenCentral() everywhare

Before

 repositories {
        google()
        jcenter()
 }

After

 repositories {
        google()
        mavenCentral()
 }

Good luck.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leonardo Castro
Solution 2 Sergey Salnikov
Solution 3 THEODORE