Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find method testImplementation() for arguments [junit:junit:4.12]

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha06'
    implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha06'
    implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha06'
    implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha06'
    implementation 'com.android.support:design: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'
}

This is my build.gradle file and I tried many ways but I can't fix this, when I start Android Studio and gradle starts build the project Android Studio throw this error how can I fix it?( I am new in Android)

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

like image 769
O.Ufuk Avatar asked Oct 01 '18 11:10

O.Ufuk


3 Answers

It is Google's fault.You need to use your countries letters.So use 'İ' instead 'I'.

testİmplementation  'junit:junit:4.12'
androidTestİmplementation  'androidx.test:runner:1.1.1'
androidTestİmplementation  'androidx.test.espresso:espresso-core:3.1.1'
like image 200
NecroMancer Avatar answered Nov 09 '22 08:11

NecroMancer


Well, I know that's not the nicest solution for this but this is what worked. I simply commented these lines out:

//testImplementation "junit:junit:4.12"
//testImplementation "org.robolectric:robolectric:3.1.2"

Hope it helps =)

like image 7
gmartinsnull Avatar answered Nov 09 '22 10:11

gmartinsnull


Can you provide your Gradle version and complete build.gradle ?

Possible issues:

  1. You are missing a plugin definition apply plugin: 'com.android.application'

or any plugin that implicitly uses the Java Plugin ? That's where the testImplementation comes from.

  1. You're using < Gradle 3.x (testImplementation is not available in the previous releases)

Ensure you are using Gradle 3.x+ and that the top level build.gradle has Android Gradle Plugin 3.x+ defined in it : https://developer.android.com/studio/releases/gradle-plugin#updating-plugin

like image 2
jabubake Avatar answered Nov 09 '22 10:11

jabubake