目前我解决这个问题的办法就是
在项目外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
----------------------------------------------旧内容------------------------------------------------------------------
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'
也可以使用