升级到Android Studio 3.1,重新构建项目时报错,主要错误为:
The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
instrumentTest已被废弃,新的Gradle插件已经不支持。instrumentTest需要修改为androidTest。
修改后,sourceSets相关内容类似:
android {
buildToolsVersion "27.0.3"
compileSdkVersion 24
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest.setRoot('tests')
}
}