安卓11报错:Failed to resolve: com.github.xxxx:14.0 Show in Project Structure dialog Affecte

本篇文章主要讲解,安卓11版本情况下项目运行报错 Failed to resolve: com.github.getActivity:Toaster:14.0 Show in Project Structure dialog Affected Modules: app的主要原因及解决办法。
作者: 任聪聪
独立博客: https://rccblogs.com/631.html
日期:2024年8月28日

具体报文信息:

Failed to resolve: com.github.getActivity:Toaster:14.0
Show in Project Structure dialog
Affected Modules: app

主要原因说明:

通过提示信息我们可以看出这里说了某个依赖无法进行导入,这种情况表明实际我们引入的库中是没有这个版本的依赖的,故此解决的办法也很多。

解决方法:

1.更换版本号

替换14.0改为 12.2

2.更换仓库源

修改根目录下的 setting.gradle 文件,写入如下代码即可配置:

pluginManagement {
    repositories {
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
        maven { url 'https://jitpack.io' }
        maven { url 'https://developer.huawei.com/repo/' }
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
        //华为云镜像
        maven { url 'https://developer.huawei.com/repo/' }
        //阿里云
        maven { url 'https://mirrors.aliyun.com/nexus/content/groups/public/' }
        //清华大学的镜像
        maven { url 'https://mirrors.tuna.tsinghua.edu.cn/nexus/content/groups/public/' }
        //同济大学的镜像
        maven { url 'https://mirrors.sjtug.sjtu.edu.cn/nexus/content/groups/public/' }
    }
}

具体位置:
file

猜你喜欢

转载自blog.csdn.net/hj960511/article/details/141649028