3

Updated to Android Studio 3.1 and its corresponding gradle. I'm getting a message when trying to sync "The SourceSet 'robolectric' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?".

Here is the current sourceSet in the gradle file:

sourceSets {
    main {
        java.srcDirs = ['src/main/java']
    }
    robolectric {
        java.srcDir file('src/test/java/')
        resources.srcDir file('src/test/resources')
    }
}
1
  • 1
    did you find answer? if so, please post it here.. Sep 19, 2018 at 11:46

1 Answer 1

0

The defined sourceSet must match an already defined buildType or productFlavor. This excludes main which is defined by default.

buildTypes {
        debug {
           //TODO: Your buildType config here
        }

        robolectric {
           //TODO: Your buildType config here
        }
}

sourceSets {
    main {
        java.srcDirs = ['src/main/java']
    }
    robolectric {
        java.srcDir file('src/test/java/')
        resources.srcDir file('src/test/resources')
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.