1,gradle-wrapper.properties 更改distributionUrl到最新 如下:gradle-4.4-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
2,检查所有build.gradle文件 更改过时配置
compile拆成了两个:implementation只在本Module中有效,api对所有Module都有效
compile 替换为 implementation/api
instrumentTestCompile/androidTestCompile 替换为 androidTestImplementation/androidTestApi
instrumentTest 替换为 androidTest
testCompile 替换为 testImplementation/testApi
debugCompile 替换为debugImplementation
releaseCompile 替换为 releaseImplementation
apt 替换为 annotationProcessor
3,检查project层级build.gradle文件 配置google()
如果不配置 会报错:Failed to resolve:
//注意:google()放在jcenter()前面,不然会报Could not find runtime.jar (android.arch.lifecycle:runtime:1.1.0)错误.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
4,检查所有build.gradle中buildTypes配置要一致
比如主Module配置了tesing 其他所有module中也要配置相同的. 否则会报错:Unable to resolve dependency for ‘:app@tesing/compileClasspath’: Could not resolve project
buildTypes {
tesing{
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}