Pushwoosh / pushwoosh-flutter

Pushwoosh Flutter Plugin
Other
8 stars 16 forks source link

Android build failed on app:releaseRuntimeClasspath due to 502 bad gateway error #46

Closed matszafraniec closed 2 years ago

matszafraniec commented 2 years ago

Hello,

I'm getting this error while trying to build Android app.

Execution failed for task ':app:mergeReleaseAssets'.

> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.

   > Could not resolve androidx.work:work-runtime:[2.0.0, 2.6.99].

     Required by:

         project :app > project :pushwoosh > com.pushwoosh:pushwoosh:6.3.3

      > Failed to list versions for androidx.work:work-runtime.

         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml.

            > Could not get resource 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml'.

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

I can see there is reference to external resource which is not available. It can be fixed?

I'm using pushwoosh ver 2.1.0. Flutter 2.8.0

teknofreek commented 2 years ago

i have the samae error. any updates?

nikolleto commented 2 years ago

@matszafraniec @teknofreek We were using Jcenter/ Bintray in our previous releases and it was deprecated about a year ago. While they've promised to keep it hosted in a read only state "indefinitely", downtime is quite frequent.

However, starting with version 2.2.0 we have switched all our packages to mavenCentral repository. Updating your package to one of the latest releases should fix that issue.

matszafraniec commented 2 years ago

@nikolleto are you sure it's updated in new version? I have installed 2.2.1 and error is still there:

* What went wrong:
Execution failed for task ':app:mergeReleaseAssets'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve androidx.work:work-runtime:[2.0.0, 2.6.99].
     Required by:
         project :app > project :pushwoosh > com.pushwoosh:pushwoosh:6.3.5
      > Failed to list versions for androidx.work:work-runtime.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/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 3m 45s
Running Gradle task 'assembleRelease'...                          227.2s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Running Gradle task 'assembleRelease'...                        

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve androidx.work:work-runtime:[2.0.0, 2.6.99].
     Required by:
         project :app > project :pushwoosh > com.pushwoosh:pushwoosh:6.3.5
      > Failed to list versions for androidx.work:work-runtime.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/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 2m 12s
Running Gradle task 'assembleRelease'...                          133.1s
[!] Gradle threw an error while downloading artifacts from the network. Retrying to download...
Gradle task assembleRelease failed with exit code 1

in pubspec.lock I have:

  pushwoosh:
    dependency: "direct main"
    description:
      name: pushwoosh
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.1"
nikolleto commented 2 years ago

@matszafraniec I'm sure as you can see in the source files.

Nevertheless, it looks like the issue may be with the repositories configuration in your project as I can't reproduce the issue in the public sample. I would like to ask you to share your build.gradle file to us to reproduce the issue to give you more reliable answer to the problem. You can find the file in the following path "YOUR_FLUTTER_APP/android/build.gradle".

matszafraniec commented 2 years ago

Here you can find it @nikolleto

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

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.5'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.0'
    }
}

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

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
nikolleto commented 2 years ago

@matszafraniec Thank you for your patience! We were unable to reproduce this behavior with your build.gradle, so could you please let us know if you still experience the issue? If you do, could you please try replacing jcenter() repository with mavenCentral() in your gradle files and let us know about the result?

matszafraniec commented 2 years ago

@nikolleto I have changed it and still have same issue:

Running Gradle task 'assembleRelease'...                        

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve androidx.work:work-runtime:[2.0.0, 2.6.99].
     Required by:
         project :app > project :pushwoosh > com.pushwoosh:pushwoosh:6.3.3
      > Failed to list versions for androidx.work:work-runtime.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/androidx/work/work-runtime/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 3m 39s
Running Gradle task 'assembleRelease'...                          220.7s
wfhm commented 2 years ago

@matszafraniec the issue is caused by Google Bintray sunset - when building the project, gradle tries to get a list of available versions for all dependencies, and, as Bintray returns 502 error, it fails to get this list, only working for the dependencies with a particular version specified. We are looking for a reliable fix right now, meanwhile, you can use the workaround from https://github.com/Pushwoosh/pushwoosh-flutter/issues/48:

    constraints {
        implementation('androidx.work:work-runtime') {
          version {
            strictly '2.7.0'
            }
        }
    }
wfhm commented 2 years ago

@matszafraniec Hi, could you please let us know if the issue still persists in your project? I have tried reproducing it recently, and it worked fine in several demo projects we use and in a brand new project built with the latest Flutter and Pushwoosh plugin versions. It looks like replacing jcenter() with mavenCentral() in your build.gradle solves the issue. Also, it seems that Gradle now uses its own JCenter mirror that does not return 502 response, so it might be a good idea to use the latest gradle plugin version.

matszafraniec commented 2 years ago

Hello @wfhm , thank you for your support. I will let you know in next week, because currently I'm busy with other tasks.

wfhm commented 2 years ago

@matszafraniec closing this thread as everything seems to be working fine. However please feel free to reopen it shall the issue reappear.

matszafraniec commented 2 years ago

In my project we were updated Flutter to latest version and packages including Pushwoosh plugin (2.2.3) and I can confirm that issue is resolved. Thank you 👍