Android Studio更新3.6.3之后出现Could not resolve all artifacts for configuration :classpath. 问题

目前我解决这个问题的办法就是
在项目外bulid.gradle在这里插入图片描述
修改为以下内容


buildscript {
    ext.kotlin_version = '1.3.72'
    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()
        /*
		 google()
        jcenter()
		*/
    }
    dependencies {
    //修改这里,将版本修改为3.6.1即可
        classpath 'com.android.tools.build:gradle:3.6.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // 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()
        /*
		google()
        jcenter()  
        */
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

再修改项目内的bulid.gradle
在这里插入图片描述


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    //修改这里,版本修改为1.2.0,没有就不用修改
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

剩下旧内容为修改模板,减少创建新项目时多余操作。
能跑就行.jpg
----------------------------------------------旧内容------------------------------------------------------------------

你是否和我一样,只因在人群中多看了他一眼?

在这里插入图片描述

再也没能摆脱**的问题

在这里插入图片描述

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'

也可以使用

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一天发火两次

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值