Android Studio 无法加载模块:situeb.com

w7t8yxp5  于 2022-11-30  发布在  Android
关注(0)|答案(2)|浏览(206)

在Android Studio中添加XML文件时出现红色下划线。如何解决?
它显示:Unable to resolve dependency for ':app@debug/compileClasspath':Could not resolve com.github.smarteist:autoimageslider:1.4.0

0h4hbjxa

0h4hbjxa1#

检查您的build.gradle中是否缺少jcenter(),如果需要,请添加它。

allprojects {
    repositories {
        google()
        //here
        jcenter()
        mavenCentral()
   
    }
}

enter image description here

dsf9zpds

dsf9zpds2#

您需要在settings.gradle内的dependencyResolutionManagement中添加依赖项。
自7.X.X gradle构建工具起,allprojects已被弃用使用dependencyResolutionManagement是声明存储库的最佳实践。
因此,Android项目将不再在其项目build.gradle文件中生成allprojects块,而是在settings.gradle中生成dependencyResolutionManagement块。

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter() // Warning: this repository is going to shut down soon

        // e.g this is how you would add jitpack
        maven { url "https://jitpack.io" }
        // Add any repositories you would be adding to all projects here
    }
}

相关问题