bug描述
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.
产生原因
- 一般可能是更换了新AndroidStudio导致的。
- 依赖库未能成功下载
解决办法
1.新版本AndroidStudio解决办法
该方法不行就使用下面的旧版本方法试试
注意:修改的是,项目的根目录下的settings.gradle文件内容
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { url "https://jitpack.io" }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "My Application"
include ':app'
2.旧版本AndroidStudio用下面的办法
注意:修改的是,项目的根目录下的build.gradle文件内容
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
jcenter()
maven { url "https://jitpack.io" }
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
jcenter()
maven { url "https://jitpack.io" }
}
}
出现该问题的背景介绍
由于有多个项目同时开发,其中一个项目工程出现了问题,开发布局时不智能提示相关属性如id等,最后通过更换AndroidStudio解决掉的,然后回头来开发其他项目时发现工程跑不起来了,各种报错,其中一个错误就是:
Caused by: org.gradle.api.internal.artifacts.ivyservice.
DefaultLenientConfiguration$ArtifactResolveException: Could
not resolve all files for configuration ':app:debugCompileClasspath'.
顿时我蒙蔽了,前几天还好好的呢。根据解释应该是gradle出现了问题,于是各种调试,都没解决。最后的解决办法就是上面说的更换回之前的AndroidStudio就好了。但我刚发现之前的不提示属性问题又出现了。
关于androidstudio 布局文件不提示属性问题如图:
打id时不提示id属性,解决办法如图:
修改 app的build.gradle中的compileSdk版本,改完后同步,再试试。