【问题标题】:My flutter Android build broke all sudden with a gradle error, with no changes to the gradle configuration on my part我颤动的 Android 构建突然因 gradle 错误而崩溃,我的 gradle 配置没有任何更改
【发布时间】:2022-01-12 21:18:05
【问题描述】:

出乎意料的是,在构建我的 Flutter 应用程序 Android 版本时,我开始收到以下构建错误。构建工作正常,然后突然间开始出现此错误。

我没有更改我的 pubspec.yaml 依赖项,也没有更改我的任何 gradle 配置文件。我一直在使用当前的 gradle 配置来构建很长时间而没有错误。我不确定如何在不更改构建系统的情况下弹出此错误。

我已经研究过这个错误,似乎很多修复它的建议是在 gradle-wrapper.properties 中修改 gradle 版本。我已经将版本从 5.6 升级到 6.7 再到 7.2,试图解决这个问题,但这些更改都没有奏效。我在这些变化之间跑得很干净。

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.flutter:x86_64_debug:1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_debug:1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.
         > Could not get resource 'https://jcenter.bintray.com/io/flutter/x86_64_debug/1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6/x86_64_debug-1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.pom'.
            > Could not GET 'https://jcenter.bintray.com/io/flutter/x86_64_debug/1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6/x86_64_debug-1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.pom'. Received status code 502 from server: Bad Gateway
   > Could not resolve io.flutter:x86_debug:1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.
         > Could not get resource 'https://jcenter.bintray.com/io/flutter/x86_debug/1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6/x86_debug-1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.pom'.
            > Could not GET 'https://jcenter.bintray.com/io/flutter/x86_debug/1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6/x86_debug-1.0.0-890a5fca2e34db413be624fc83aeea8e61d42ce6.pom'. 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 22s

【问题讨论】:

    标签: android flutter gradle bintray


    【解决方案1】:

    您可以在项目级别的 build.gradle 中替换 jcenter() by mavenCentral()

    之前:

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

    之后:

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

    【讨论】:

      【解决方案2】:

      几个小时前我也遇到了这个问题。我使用的是最新的 Flutter SDK 2.8.1。我寻找解决方案并尝试了很多事情。更新了所有插件,Gradle 版本,但没有任何效果。

      然后我刚刚将 Flutter 降级到 2.5.3,现在可以正常工作了。

      我认为这是 Flutter 最新版本中的问题,或者jcenter 站点中可能存在问题。

      不过,目前降级可能是一种解决方法,我希望 Flutter 团队尽快解决这个问题。

      【讨论】:

        【解决方案3】:

        即使它被标记为弃用和日落,jcenter 仍将无限期地保持为读取 depo。可能是您对 bintray 的依赖或可能是 gradle 本身已放弃支持。您可能需要寻找替代方案。

        https://blog.gradle.org/jcenter-shutdown

        更新:JFrog 已决定将 JCenter 无限期地保留为只读存储库。 JCenter 不再接受新的包和版本。所有 Bintray 服务均已关闭。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-10-24
          • 2014-10-22
          • 1970-01-01
          • 1970-01-01
          • 2017-10-06
          • 1970-01-01
          • 2015-12-28
          • 1970-01-01
          相关资源
          最近更新 更多