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

后端 未结 6 1260
盖世英雄少女心
盖世英雄少女心 2020-12-29 01:50

I updated the AndroidStudio to version 3.1

Clean Project...

and build failed

The SourceSet \'instrumentTest\' is not recognized by the Androi         


        
相关标签:
6条回答
  • 2020-12-29 02:27

    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')
        }
    }
    
    0 讨论(0)
  • 2020-12-29 02:27

    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')
        }
    
    0 讨论(0)
  • 2020-12-29 02:28

    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

    0 讨论(0)
  • 2020-12-29 02:29

    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

    0 讨论(0)
  • 2020-12-29 02:29

    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.

    0 讨论(0)
  • 2020-12-29 02:40

    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

    0 讨论(0)
提交回复
热议问题