如何解决Android Studio中的Gradle sync失败错误?

时间:2018-01-21 10:50:37

标签: android android-studio android-gradle

错误消息是:

Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.
Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.
Required by:project :app
Could not resolve com.android.support:appcompat-v7:26.0.0-beta1.
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.0.0-beta1/appcompat-v7-26.0.0-beta1.pom'.
Could not GET 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.0.0-beta1/appcompat-v7-26.0.0-beta1.pom'.
sun.security.validator.ValidatorException: 
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target
unable to find valid certification path to requested target 

2 个答案:

答案 0 :(得分:1)

而不是

com.android.support:appcompat-v7:26.0.0-beta1

指定:

com.android.support:appcompat-v7:26.0.0

答案 1 :(得分:0)

在项目中使用Beta-1会产生问题,因为测试版文件会在很短的时间内更新,因此无法从链接获取同步,始终使用稳定版本 尝试使用

implementation 'com.android.support:appcompat-v7:26.1.0'

compile 'com.android.support:appcompat-v7:26.1.0'