ArtifactResolveException

bug描述

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugCompileClasspath'.

产生原因

  1. 一般可能是更换了新AndroidStudio导致的。
  2. 依赖库未能成功下载

解决办法

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版本,改完后同步,再试试。

相关推荐
移动开发者1号2 小时前
ReLinker优化So库加载指南
android·kotlin
山野万里__2 小时前
C++与Java内存共享技术:跨平台与跨语言实现指南
android·java·c++·笔记
Huckings2 小时前
Android 性能问题
android
移动开发者1号2 小时前
剖析 Systrace:定位 UI 线程阻塞的终极指南
android·kotlin
移动开发者1号2 小时前
深入解析内存抖动:定位与修复实战(Kotlin版)
android·kotlin
whysqwhw2 小时前
OkHttp深度架构缺陷分析与革命性演进方案
android
Digitally4 小时前
如何将文件从 iPhone 传输到 Android(新指南)
android·ios·iphone
whysqwhw5 小时前
OkHttp深度架构缺陷分析与演进规划
android
用户7093722538515 小时前
Android14 SystemUI NotificationShadeWindowView 加载显示过程
android
木叶丸6 小时前
跨平台方案该如何选择?
android·前端·ios