You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter插件构建时遭遇SSL握手异常问题求助

Flutter插件构建时遭遇SSL握手异常问题求助

我用以下命令生成了一个Flutter插件:

flutter create --template=plugin --platforms=android,ios new_plug

但是执行插件的时候,遇到了下面的构建异常:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
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 androidx.test:runner:1.2+.
     Required by:
         project :app > project :integration_test
      > Failed to list versions for androidx.test:runner.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/runner/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/runner/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      > Failed to list versions for androidx.test:runner.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/runner/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/runner/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve androidx.test:rules:1.2+.
     Required by:
         project :app > project :integration_test
      > Failed to list versions for androidx.test:rules.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/rules/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/rules/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      > Failed to list versions for androidx.test:rules.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/rules/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/rules/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve androidx.test.espresso:espresso-core:3.2+.
     Required by:
         project :app > project :integration_test
      > Failed to list versions for androidx.test.espresso:espresso-core.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/espresso/espresso-core/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/espresso/espresso-core/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      > Failed to list versions for androidx.test.espresso:espresso-core.
         > Unable to load Maven meta-data from https://dl.google.com/dl/android/maven2/androidx/test/espresso/espresso-core/maven-metadata.xml.
            > Could not HEAD 'https://dl.google.com/dl/android/maven2/androidx/test/espresso/espresso-core/maven-metadata.xml'.
               > Got SSL handshake exception during request. It might be caused by SSL misconfiguration
                  > 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 34s
Error: Gradle task assembleDebug failed with exit code 1

项目结构以截图形式展示:

我已经尝试过的方法:

  • 在与example目录同级的android目录下,新建了gradle.properties文件,并添加了以下配置:
systemProp.gradle.internal.http.connectionTimeout=60000
systemProp.gradle.internal.http.socketTimeout=60000
systemProp.gradle.internal.http.sslVerify=false

我的环境版本信息:

  • Android Studio Koala 2024.1.1
  • Android SDK 14.0 API level 34

提前感谢大家的帮助😊

备注:内容来源于stack exchange,提问作者Rishi Raj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 10:44:33