Android Studio更新3.6.3之後出現Could not resolve all artifacts for configuration ':classpath'.問題
你是否和我一樣,只因在人羣中多看了他一眼?
再也沒能擺脫**的問題
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'hello6'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not download gradle.jar (com.android.tools.build:gradle:3.6.3)
> Could not get resource 'https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.6.3/gradle-3.6.3.jar'.
> Could not HEAD 'https://maven.aliyun.com/repository/google/com/android/tools/build/gradle/3.6.3/gradle-3.6.3.jar'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not download jetifier-core.jar (com.android.tools.build.jetifier:jetifier-core:1.0.0-beta08)
> Could not get resource 'https://maven.aliyun.com/repository/google/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta08/jetifier-core-1.0.0-beta08.jar'.
> Could not HEAD 'https://maven.aliyun.com/repository/google/com/android/tools/build/jetifier/jetifier-core/1.0.0-beta08/jetifier-core-1.0.0-beta08.jar'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not download baseLibrary.jar (com.android.databinding:baseLibrary:3.6.3)
> Could not get resource 'https://maven.aliyun.com/repository/google/com/android/databinding/baseLibrary/3.6.3/baseLibrary-3.6.3.jar'.
> Could not HEAD 'https://maven.aliyun.com/repository/google/com/android/databinding/baseLibrary/3.6.3/baseLibrary-3.6.3.jar'.
> sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'hello6'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:80)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:73)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$600(LifecycleProjectEvaluator.java:53)
at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject$1.run(LifecycleProjectEvaluator.java:109)
at org.gradle.internal.Factories$1.create(Factories.java:26)
at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:189)
at org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:227)
at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withMutableState(DefaultProjectStateRegistry.java:221)
at
... 50 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
... 65 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
... 65 more
* Get more help at https://help.gradle.org
CONFIGURE FAILED in 1s
之前Android Stdio還好好的突然出現這種問題,作爲萌新黨很無奈。
明明纔剛進了新手村(第N次進了),卻直接遇到個致命Boss。老手不會遇到,新手不會解決。
看了很多方法,下載證書,換國產鏡像,改本機Host都沒能解決。
後來看到了網站地址 這篇文章第一個方法後才解決了使用的問題。(能跑就行了,要啥自行車。)
那麼問題來了,有這麼簡單的方法要這篇文章幹嘛。
這篇文章爲了解決每次創建新項目時都要手動修改配置的麻煩,提供解決方法。
打開${Android\Android Studio安裝目錄}\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root\build.gradle.ftl 這個文件
${Android\Android Studio安裝目錄}指的是Android Stdio安裝的位置
我是這樣配置的
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
<#if generateKotlin>ext.kotlin_version = '${kotlinVersion}'</#if>
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url'https://maven.aliyun.com/repository/public/' }
maven { url'https://maven.aliyun.com/repository/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
maven { url'https://maven.aliyun.com/repository/central/' }
mavenLocal()
mavenCentral()
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
<#if generateKotlin>classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"</#if>
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url'https://maven.aliyun.com/repository/public/' }
maven { url'https://maven.aliyun.com/repository/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
maven { url'https://maven.aliyun.com/repository/central/' }
mavenLocal()
mavenCentral()
<#if includeKotlinEapRepo!false>maven { url '${kotlinEapRepoUrl}' }</#if>
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
然後保存。重新創建一個新項目就能直接用了。
//就這麼小的問題我都要解決一天,嗚嗚嗚~
更新
classpath 'com.android.tools.build:gradle:3.6.1'
也可以使用