The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin

ε祈祈猫儿з 提交于 2019-11-29 00:50:25

instrumentTest has been deprecated and does not work with modern Gradle versions - which you probably updated in your project when upgrading Android Studio.

Replace instrumentTest with androidTest and it'll work.

Replace instrumentTest by androidTest as example below

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

Try change distributionUrl in you gradle/wrapper/gradle-wrapper.properties to last vesion:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

clean project and "Invalidate Cache/Restart" in File menu after this

Try with the Android Studio 3.1.2 update, which has a fix for this bug: https://developer.android.com/studio/releases/index.html#3-1-0

1.you will face this type of issue while upgrading the gradle files 2.if ur project implements any payment gateways in their gradle file you find this "instrumentTest.setRoot('tests')".

Solution simple just replace this "instrumentTest.setRoot('tests')" with androidTest as show below images...

It will work @Ambilpura

Just Replace instrumentTest by androidTest

sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

      //  instrumentTest.setRoot('tests')
        androidTest.setRoot('tests')
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!