,但是从gradle版本,和gradle插件版本号在7.0之后,自定义源的方式稍有不同,折腾半天,记录一下。
在之前我们是在build.gradle(project)中去配置:(7.0版本以下都可以用这个方法)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven {
url "https://jitpack.io"
}
maven {
url "http://dl.bintray.com/lukaville/maven"
}
maven {
url "https://maven.google.com/"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
但是7.0之后有变化
但是在gradle7.0后使用这种方法会报Build was configured to prefer settings repositories over project repositories but repository 'maven的错误,我们将build.gradle(project)恢复到初始状态:
然后到项目的setting.gradle中去配置
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "MyFloatButton"
include ':app'