Android Gradle插件报错:The SourceSet 'instrumentTest' is not recognized

升级到Android Studio 3.1,重新构建项目时报错,主要错误为:

The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?

instrumentTest已被废弃,新的Gradle插件已经不支持。instrumentTest需要修改为androidTest。

即 

  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')

    }

 

你可能感兴趣的:(android)