Could not find method testCompile() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

i have been using the build file below for a while with no problems.

suddenly i am getting this error message.

i am using gradle 3.1

repositories {
jcenter()
}
dependencies {
testCompile ‘junit:junit:4.12’
}
sourceCompatibility = 1.7
targetCompatibility = 1.7

i accidently deleted the java plugin :frowning:

I am getting the same error. Can you please explain in detail?

The testCompile configuration to which the JUnit dependency is added is created by some plugin.
If you for example apply the java, groovy or kotlin plugin, this configuration will be present and you can add dependencies to it. If you remove all the plugins that would have added that configuration, you get the mentioned error.