Could Not build Flutter Android Build : Received status code 502 from server: Bad Gateway

Viewed 2774

Hi I am trying to build my flutter app (debug/release). Every thing were fine till yesterday but Today since morning If I build my app (debug/release) I am facing below exception

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:processDevDebugResources'.
> Could not resolve all task dependencies for configuration ':app:devDebugRuntimeClasspath'.
   > Could not resolve com.google.android.gms:play-services-location:16.+.
     Required by:
         project :app > project :location
      > Failed to list versions for com.google.android.gms:play-services-location.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

These are my Flutter and Dart Versions:

  • Flutter 2.5.3
  • Dart 2.14.4

Location Plugin :

location: ^4.3.0

Distribution URL in gradle.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

Project Level Gradle:

buildscript {
    ext.kotlin_version = '1.4.21'
    repositories {
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.4.1'

    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
1 Answers

Thanks for response on my Question. After spending long time I found the solution.

I followed some steps below :

Update gradle.properties file as:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

Update dependency in project level build.gradle file as:

classpath 'com.android.tools.build:gradle:4.0.1'

Clean and get pug:

flutter clean
flutter pub get

Now build your project. It worked successfully.

I guess my issue was related to distributionUrl

Related