android - 未找到 Gradle DSL 方法 : 'testimplementation()' ?

标签 android android-gradle-plugin

Gradle DSL method not found: 'testimplementation()' 

项目“我的项目”可能使用不包含该方法的 Gradle 版本。 构建文件可能缺少 Gradle 插件。 应用gradle插件

我已经尝试过

  1. 删除重新同步的项目 .gradle
  2. 使/缓存无效并重新启动使用
  3. 本地 gradle 分发选项

Gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.techknocorp.a.metturcable"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 532016
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testimplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    androidTestImplementation 'com.android.support.test:runner:1.1.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso- 
 core:3.1.1'
    implementation files('libs/opencsv-2.3.jar')
}

顶级 Gradle //顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
 }

 task clean(type: Delete) {
    delete rootProject.buildDir
 }

最佳答案

使用testImplementation而不是testimplementation

dependencies {
    //....
    testImplementation 'junit:junit:4.12'
    //..
}

关于android - 未找到 Gradle DSL 方法 : 'testimplementation()' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56255819/

相关文章:

java - 如何调用 run() 无限次刷新屏幕信息,直到用户关闭应用程序

java - 白屏挂起与谷歌分析安卓

android - 在Kotlin项目中应用Realm插件导致编译报错

android - Android Studio 在运行仪器测试时如何确定模块?

android - 使用 Polygon 在整个 map 上绘制一个矩形

android - android中大小写敏感

android - 在 Android Studio 0.5.1 上导入 Facebook SDK

Android 在发布 apk 时构建失败

android - 如何在模块和应用程序中导入 .jar 文件?

android - 通过 intents 传递大量数据时崩溃 - extras 包是否有大小限制?