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

相关推荐
Digitally8 小时前
6 款优质安卓备份提取工具与备份方案
android
恋猫de小郭11 小时前
Flutter A2UI 1.0 ,原来的 genui 也正式换成了这一套 SDK 了
android·前端·flutter
Wellijohn1 天前
一个 Android 老兵的十年开源路:从 167 star 的滑动控件,到本地优先的 AI Agent
android·人工智能·开源
好的佩奇1 天前
Dart 之元数据与注解
android·flutter·dart
三少爷的鞋1 天前
很多开发者把物理上的分层,当成了架构
android
FungLeo1 天前
FengCMS · PHP+MySQL 升级实录 · MySQL DDL不能回滚:模型字段结构操作的失败续做
android·mysql·php·工程实践·fengcms
雨白1 天前
Android 建造者模式实战:从 AlertDialog 源码到 TopBar 的两种实现
android
_祝你今天愉快1 天前
Android 高级绘制:[五] 贝塞尔曲线与计算规则
android
FungLeo2 天前
FengCMS · PHP+MySQL 升级实录 · 危险默认值之殇:root/123456、认证码 8888 写进配置加载器
android·mysql·php·安全加固·fengcms
yz_aiks2 天前
Termux 使用教程:把安卓手机变成随身 Linux(装 Python、SSH 远程、跑自动化脚本)
android·linux·python·智能手机·ssh·termux