Build was configured to prefer settings repositories over project repositories but repository ....问题

2年前 (2022) 程序员胖胖胖虎阿
239 0 0

关于“ Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle' ” 问题的解决方案

本人的原因:增加kotlin的兼容支持;当然还有其他原因导致,这里不细述;

有用解法步骤如下:

1,将setting.gradle文件的该配置注释掉:

//dependencyResolutionManagement {
//    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
//    repositories {
//        google()
//        mavenCentral()
//        jcenter() // Warning: this repository is going to shut down soon
//        maven { url 'https://jitpack.io' }
//    }
//}

2,在根目录下的build.gradle文件中增加如下配置:

allprojects {
    repositories {
        google()
        mavenCentral()
//        jcenter() // Warning: this repository is going to shut down soon
    }
}

3,然后点击按钮“sync project with gradle files”即可正常

注意:

1,也找了线上大多数的解决办法,例如这里的:android - Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle' - Stack Overflow

但是并不解决问题,所以放弃

相关文章

暂无评论

暂无评论...