可以在 build.gradle
里面加入以下代码
- maven 源置换
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2/'
name 'Google'
}
def REPOSITORY_URL = 'https://dl.google.com/dl/android/maven2/'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://maven.google.com')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
}
}
- compileSdkVersion 以及 buildToolsVersion 版本统一
subprojects {
afterEvaluate {
project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
}
}
}
}
- support 依赖版本统一
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "27.1.0"
}
}
}
}