0
votes

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

I updated the android studio yesterday and created a new project but error during the gradle sync synchronization.

FAILURE: Build failed with an exception.

  • Where: Build file 'D:\Android Project\dnm\app\build.gradle' line: 25

  • What went wrong: A problem occurred evaluating project ':app'.

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

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

CONFİGURE FAILED in 25s ERROR: Could not find method testImplementation() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. Open File

buildscript
{
    repositories {
        google()
        jcenter()  
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0' } 
}
allprojects { 
    repositories { 
        google() 
        jcenter() 
    }
}

and my gradle properties

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

and my gradle build

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.denemeuygulamasi.dnm"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
2

2 Answers

1
votes

Today I had same issue , after update to 3.3

I uninstall and delete gradle directory android directory etc nothing worked but then I wrote

testİmplementation instead of testImplementation and androidTestİmplementation

it worked basically , I don't know why , but you can try and write if you find better solution please because I have to do this to every project I create

1
votes

Did you add it's dependency?

I think you need to add in build gradle dependencies

testImplementation 'junit:junit:4.12'

Or delete .gradle and .idea then invalidate cache and restart enter image description here