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
}