Flutter构建Android平台Bug

Flutter Bug记录

用AS新建一个Flutter,iOS平台能跑起来,Android平台跑步起来,查了很多资料最后整出了,只要坚持就能柳暗花明!

1 环境

Mac(M1 pro)+ Android Studio

2 运行构建时失败出错

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/flutter_embedding_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/flutter_embedding_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/arm64_v8a_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/arm64_v8a_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:x86_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:x86_64_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_64_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_64_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake

* 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 15s
Retrying Gradle Build: #1, wait time: 100ms
[!] Gradle threw an error while downloading artifacts from the network.
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/flutter_embedding_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/flutter_embedding_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:arm64_v8a_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/arm64_v8a_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/arm64_v8a_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:x86_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake
   > Could not resolve io.flutter:x86_64_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_debug:1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_64_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad/x86_64_debug-1.0.0-f40e976bedff57e69e1b3d89a7c2a3c617a03dad.pom'.
               > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.5/userguide/build_environment.html#gradle_system_properties
                  > Remote host terminated the handshake

* 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 5s
[!] Gradle threw an error while downloading artifacts from the network.
Exception: Gradle task assembleDebug failed with exit code 1

解决办法

找到 android 目录下的build.gradle , 找到repositories,添加如下代码:

 repositories {
        google()
        mavenCentral()
        maven {
            url "http://download.flutter.io"
            allowInsecureProtocol = true
        }
    }

完整文件如下:

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
        maven {
            url "http://download.flutter.io"
            allowInsecureProtocol = true
        }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url "http://download.flutter.io"
            allowInsecureProtocol = true
        }
    }
}

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

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值