PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
配置安卓环境变量:
打开 Android Studio,选择 Confiure -> 'SDK Manager':
vim ~/.bash_profile
export ANDROID_HOME=/Users/XXX/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
source ~/.bash_profile
此错误,也可能是因为别的方式解决的,在莫名其妙的情况下好的……
新错误:
* What went wrong:
Execution failed for task ':app:desugarDebugFileDependencies'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not download flutter_embedding_debug.jar (io.flutter:flutter_embedding_debug:1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32)
> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.jar'.
> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32/flutter_embedding_debug-1.0.0-6bc433c6b6b5b98dcf4cc11aff31cdee90849f32.jar'.
> Connect to storage.googleapis.com:443 [storage.googleapis.com/216.58.200.240] failed: connect timed out
解决:找到android->build.gradle,buildscript repositories 的 google()
改为maven { url "https://dl.google.com/dl/android/maven2/" }
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
// google()
maven { url "https://dl.google.com/dl/android/maven2/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
重新运行即可。
原因:
应该是gradle初始化,下载文件的时候卡住了。
解决方法:
更换下载方式和路径。
附注:
此时就算改回google(),也可运行,因为依赖文件已经下载下来了。
参考资料:
flutter 项目报错:Could not resolve all files for configuration ':classpath'
解决flutter:unable to find valid certification path to requested target 的问题
类似的错误:
网友评论