使用Android Studio开发flutter项目报错:Execution failed for task ':app:checkDebugAarMetad

1,592 阅读1分钟

1、错误日志

运行main.dart报如下错误

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-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
     Required by:
         project :app
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/flutter_embedding_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/flutter_embedding_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
               > Certificate for <download.flutter.io> doesn't match any of the subject alternative names: [*.storage.googleapis.com, *.googleapis.com, commondatastorage.googleapis.com, *.commondatastorage.googleapis.com, storage.googleapis.com, storage.mtls.googleapis.com, *.appspot.com.storage.googleapis.com, *.content-storage.googleapis.com, *.content-storage-p2.googleapis.com, *.content-storage-upload.googleapis.com, *.content-storage-download.googleapis.com, *.storage-upload.googleapis.com, *.storage-download.googleapis.com]
      > Could not resolve io.flutter:flutter_embedding_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/flutter_embedding_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/flutter_embedding_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.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.4/userguide/build_environment.html#gradle_system_properties
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve io.flutter:x86_64_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://download.flutter.io/io/flutter/x86_64_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_64_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://download.flutter.io/io/flutter/x86_64_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_64_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
               > Certificate for <download.flutter.io> doesn't match any of the subject alternative names: [*.storage.googleapis.com, *.googleapis.com, commondatastorage.googleapis.com, *.commondatastorage.googleapis.com, storage.googleapis.com, storage.mtls.googleapis.com, *.appspot.com.storage.googleapis.com, *.content-storage.googleapis.com, *.content-storage-p2.googleapis.com, *.content-storage-upload.googleapis.com, *.content-storage-download.googleapis.com, *.storage-upload.googleapis.com, *.storage-download.googleapis.com]
      > Could not resolve io.flutter:x86_64_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_64_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_64_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.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.4/userguide/build_environment.html#gradle_system_properties
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve io.flutter:x86_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://download.flutter.io/io/flutter/x86_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://download.flutter.io/io/flutter/x86_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
               > Certificate for <download.flutter.io> doesn't match any of the subject alternative names: [*.storage.googleapis.com, *.googleapis.com, commondatastorage.googleapis.com, *.commondatastorage.googleapis.com, storage.googleapis.com, storage.mtls.googleapis.com, *.appspot.com.storage.googleapis.com, *.content-storage.googleapis.com, *.content-storage-p2.googleapis.com, *.content-storage-upload.googleapis.com, *.content-storage-download.googleapis.com, *.storage-upload.googleapis.com, *.storage-download.googleapis.com]
      > Could not resolve io.flutter:x86_debug:1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.pom'.
            > Could not HEAD 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_debug/1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187/x86_debug-1.0.0-e85ea0e79c6d894c120cda4ee8ee10fe6745e187.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.4/userguide/build_environment.html#gradle_system_properties
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

* 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 3s

2、解决方案

在/android/build.gradle中配置

repositories {
   google()
   mavenCentral()
   }

改为:

    repositories {
//        google()
//        mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
        maven { url "https://storage.flutter-io.cn/download.flutter.io" }
    }

须要注意是是要改的地方有两处,一模一样