Android开发之--android 添加依赖出现Failed to resolve:"你添加的依赖名"问题

发布时间 2023-03-28 09:38:45作者: 稻草人11223

运行环境是Mac,其他的库在线安装更新都是可以的,就是“m3.samlss:broccoli:1.0.0",这个库的时候,出现Failed to resolve:xxx问题,

可以锁定是添加远程仓库的问题,新版的AS是在settings.gradle里面添加:具体如下:

pluginManagement {
    repositories {
        google()
        jcenter()
        gradlePluginPortal()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url "https://maven.google.com"
        }
    }
}
rootProject.name = "HyPro_new"
include ':app'

这是我的整个文件结构,具体添加内容如下:

google()
jcenter()
maven {url "https://jitpack.io"}
maven {url "https://maven.google.com"}

上面两个地方都要添加哈!亲测有效!!!