flutter_background_fetch icon indicating copy to clipboard operation
flutter_background_fetch copied to clipboard

Received status code 502 from server: Bad Gateway!! Was Working fine till yesterday.

Open tazsid opened this issue 3 years ago • 84 comments

  • Plugin version: 1.0.3
  • Platform: Android
  • OS version: 10
  • Device manufacturer / model: Redmi 9A
  • Flutter info (Flutter 2.5.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 3595343e20 (9 weeks ago) • 2021-09-30 12:58:18 -0700 Engine • revision 6ac856380f Tools • Dart 2.14.3, Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.5.2, on Microsoft Windows [Version 10.0.19042.1348], locale en-US) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.4)
    [√] Android Studio (version 2020.3) [√] Connected device (2 available)

• No issues found!`):

Could not GET 'https://google.bintray.com/exoplayer/com/transistorsoft/tsbackgroundfetch/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

tazsid avatar Nov 30 '21 12:11 tazsid

Same here:

`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 com.transistorsoft:tsbackgroundfetch:+. Required by: project :app > project :background_fetch > Failed to list versions for com.transistorsoft:tsbackgroundfetch. > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/transistorsoft/tsbackgroundfetch/maven-metadata.xml. > Could not get resource 'https://google.bintray.com/exoplayer/com/transistorsoft/tsbackgroundfetch/maven-metadata.xml'. > Could not GET 'https://google.bintray.com/exoplayer/com/transistorsoft/tsbackgroundfetch/maven-metadata.xml'. Received status code 502 from server: Bad Gateway`

Tek56 avatar Nov 30 '21 13:11 Tek56

Post your android/build.gradle

christocracy avatar Nov 30 '21 13:11 christocracy

android/build.gradle:

buildscript {
    ext.kotlin_version = '1.5.10' // Must use 1.3.0 or higher.
    ext {
        compileSdkVersion   = 30                // or higher
        targetSdkVersion    = 30                // or higher
        appCompatVersion    = "1.0.2"           // or higher
        playServicesLocationVersion = "17.0.0"  // or higher
    }

    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            // [required] flutter_background_geolocation
            url "${project(':flutter_background_geolocation').projectDir}/libs"
        }
        maven {
            // [required] background_fetch
            url "${project(':background_fetch').projectDir}/libs"
        }
    }
}

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

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

Tek56 avatar Nov 30 '21 13:11 Tek56

Please learn to syntax highlight code blocks

christocracy avatar Nov 30 '21 14:11 christocracy

Done, sorry @christocracy

Tek56 avatar Nov 30 '21 14:11 Tek56

Do you know that the jcenter() repository is deprecated?

Look at the repositories sections of a freshly generated flutter app:

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

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

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

christocracy avatar Nov 30 '21 14:11 christocracy

Look at the android/build.gradle of the /example app here in this repo.

christocracy avatar Nov 30 '21 14:11 christocracy

Yep thanks for that, I took the example of the build gradle. I still have the issue

Could not GET 'https://google.bintray.com/exoplayer/com/transistorsoft/tsbackgroundfetch/maven-metadata.xml'. Received status code 502 from server: Bad Gateway

image

Tek56 avatar Nov 30 '21 15:11 Tek56

I have no idea why your app is attempting to find maven-metadata.xml from google.bintray.com. The maven-metadata.xml exists within the plugin

Post your updated android/build.gradle.

christocracy avatar Nov 30 '21 15:11 christocracy

i got the same on this issue

nhtdev1 avatar Nov 30 '21 15:11 nhtdev1

Screen Shot 2021-11-30 at 22 20 47

background_fetch: 1.0.3

nhtdev1 avatar Nov 30 '21 15:11 nhtdev1

This is my updated android/build.gradle

buildscript {
    ext.kotlin_version = '1.5.31'
    ext {
        compileSdkVersion   = 30
        targetSdkVersion    = 30
        supportLibVersion   = "1.3.1"
    }
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            // [required] background_fetch
            url "${project(':background_fetch').projectDir}/libs"
        }
    }
}

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

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

Tek56 avatar Nov 30 '21 15:11 Tek56

I just generated a fresh flutter app $ flutter create foo. Followed the installation steps here in this repo and the app boots without issue.

christocracy avatar Nov 30 '21 15:11 christocracy

@nhoangthinh See my comment above. I'm not looking at your posted code until you Syntax Highlight it.

christocracy avatar Nov 30 '21 15:11 christocracy

buildscript {
    ext.kotlin_version = '1.5.31' // Must use 1.3.0 or higher.
    ext {
        compileSdkVersion   = 30                // or higher
        targetSdkVersion    = 30                // or higher
        appCompatVersion    = "1.3.1"           // or higher
   }

    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.3'
        classpath 'com.google.gms:google-services:4.3.2'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            // [required] background_fetch
            url "${project(':background_fetch').projectDir}/libs"
        }
    }
}

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

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

nhtdev1 avatar Nov 30 '21 15:11 nhtdev1

@nhoangthinh See my comment above. I'm not looking at your posted code until you Syntax Highlight it. sorry @christocracy , i updated my code

nhtdev1 avatar Nov 30 '21 16:11 nhtdev1

I have no idea what your problem is. When in doubt, clean your build.

$ cd android
$ ./gradlew clean

christocracy avatar Nov 30 '21 16:11 christocracy

and $ flutter upgrade

christocracy avatar Nov 30 '21 16:11 christocracy

Still the same bug. Like you said, my app is attempting to find maven-metadata.xml from google.bintray.com. instead of searching for the one within the plugin.

I tried:

  • Updating Flutter ($ flutter ugprade)
  • Cleaning my build ($ ./gradlew clean)

About my app/versions:

  • My app is updated post-1.12
  • Flutter 2.6.0-12.0.pre.854
  • Dart 2.16.0 (build 2.16.0-55.0.dev) • DevTools 2.8.0
  • Gradle 6.3

Tek56 avatar Nov 30 '21 17:11 Tek56

I suggest you generate yourself a fresh flutter app, follow the setup instructions and verify the plugin builds fine.

christocracy avatar Nov 30 '21 17:11 christocracy

I got the same problem from yesterday

sohubill avatar Dec 01 '21 01:12 sohubill

Create for me a freshly generated flutter app which reproduces this then share that repo with me.

christocracy avatar Dec 01 '21 01:12 christocracy

There changes in android/build.gradle seen to work for me.

 buildscript {
     ext.kotlin_version = '1.4.0' // Must use 1.3.0 or higher.
     ext {
         compileSdkVersion   = 30                // or higher
         targetSdkVersion    = 30                // or higher
         appCompatVersion    = "1.2.0"           // or higher
    }
 
     repositories {
         google()
-        jcenter()
+        mavenCentral()
     }
 
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.0.1'
+        classpath 'com.android.tools.build:gradle:4.2.2'
         classpath 'com.google.gms:google-services:4.3.2'
         classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
     }
 }
 
 allprojects {
     repositories {
         google()
-        jcenter()
         maven {
             // [required] background_fetch
             url "${project(':background_fetch').projectDir}/libs"
         }
+        mavenCentral {
+            content {
+                excludeGroupByRegex "com\\.google\\.android\\.gms"
+            }
+        }
 
     }
 }

DiepEsc avatar Dec 01 '21 07:12 DiepEsc

The issue is back today, Maven is seeing this mention in build.gradle: implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '+')

and tries to get it from Bintray repository, but since bintray repository is sunset since this December it fails to get it. It's a good question why is it trying to get it from a remote repo and not local file inside plugin, but we have to force it using the local one somehow.

asmodeoux avatar Dec 08 '21 19:12 asmodeoux

Replacing the + version with an actual version name fixed the problem for me

implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '+') —> implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '0.5.0')

Also, the order of repositories matters, make sure you put

        maven {
            url './libs'
        }

above google() and mavenCentral()

asmodeoux avatar Dec 08 '21 20:12 asmodeoux

My problem it's same. My debug showing this problem today. How solve this error?

Captura de tela de 2021-12-08 17-23-11

G-Luz avatar Dec 08 '21 20:12 G-Luz

Thanks a lot @asmodeoux. @G-Luz, in app/build.gradle, add the following line: implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '0.5.0') in build.gradle, add the following lines BEFORE google() and mavenCentral(): maven { url './libs' }

Tek56 avatar Dec 08 '21 22:12 Tek56

Thanks a lot @asmodeoux. @G-Luz, in app/build.gradle, add the following line: implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '0.5.0') in build.gradle, add the following lines BEFORE google() and mavenCentral(): maven { url './libs' }

Thank you for reply. I continue received error, but it's a new error:

Captura de tela de 2021-12-08 20-01-17

My app/build.gradle:

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation(group: 'com.transistorsoft', name:'tsbackgroundfetch', version: '0.5.0')
}

apply plugin: 'com.google.gms.google-services'

My android/build.gradle:

buildscript {

    ext.kotlin_version = '1.3.0' // Must use 1.3.0 or higher.
    ext {
        compileSdkVersion = 29                // or higher
        targetSdkVersion = 29                // or higher
        appCompatVersion = "1.0.2"           // or higher
        playServicesLocationVersion = "17.0.0"  // or higher
    }

    repositories {
        maven { url './libs' }
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        maven { url './libs' }
        google()
        jcenter()
    }
}

G-Luz avatar Dec 08 '21 23:12 G-Luz

@G-Luz Look at the build.gradle from a freshly generated Flutter app that I posted above. Notice there is no jcenter.

You should not see jcenter at all. jcenter is DEAD

christocracy avatar Dec 08 '21 23:12 christocracy

Yes jcenter is DEAD, sorry. I send my build.gradle before make new changes (change to mavenCentral).

My output after change to mavenCentral():

Captura de tela de 2021-12-08 21-23-05

My android/build.gradle:

buildscript {

    ext.kotlin_version = '1.3.0' // Must use 1.3.0 or higher.
    ext {
        compileSdkVersion = 29                // or higher
        targetSdkVersion = 29                // or higher
        appCompatVersion = "1.0.2"           // or higher
        playServicesLocationVersion = "17.0.0"  // or higher
    }

    repositories {
        maven { url './libs' }
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        maven { url './libs' }
        google()
        mavenCentral()
    }
}

G-Luz avatar Dec 09 '21 00:12 G-Luz