找不到参数junit:junit:4.12的方法testImplementation()

Emi*_*ğlu 0 android-studio build.gradle android-gradle-plugin

我刚刚更新了我的android studio并创建了一个新项目,但是我现在收到此错误:

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

在这里我的摇篮:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.blurbnow.emirhan.heartkeeper_test2"
        minSdkVersion 21
        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:support-v4:28.0.0'

    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'
}
Run Code Online (Sandbox Code Playgroud)

我正在搜索它,但我找不到任何解决方案。如果有人可以帮助,我们将非常高兴。谢谢。

gok*_*sut 5

虽然不是一个完整的回答你的问题,我发现一个方法来解决这个问题:
进入项目结构>项目>和变化
摇篮版本:4.6
的Android插件版本:3.2.1
根据表这里给出:
https://开头开发商.android.com / studio / releases / gradle-plugin#updating-gradle

编辑:第一次尝试并没有奏效,但是在我更改之后,我进入了?有效。尊敬穆罕默德·埃尔多杜(Mehmet Erdogdu)!

test?mplementation 'junit:junit:4.12'
androidTest?mplementation 'com.android.support.test:runner:1.0.2'
androidTest?mplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
Run Code Online (Sandbox Code Playgroud)