现象
在老版本AS中使用 BaseRecyclerViewAdapterHelper 库的时候,需要在项目的build.gradle中引入下面的配置
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
但是在新版本中build.gradle的格式发生了很大的变化,如果写在项目的build.gradle中,会出现了下面的错误:
> Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
解决办法
在最新版本的AS中,maven仓库的配置,应该在settings.gradle文件中
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "JetpackDemo"
include ':app'