Gradle DSL方法未找到: 'testCompile()'。

11

我想在Android Studio中创建一个项目。当我运行该应用程序时,我收到以下错误信息:

Error:(10, 0) Gradle DSL method not found: 'testCompile()'
Possible causes:
-The project 'AccurateCalculator' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
-Upgrade plugin to version 2.3.2 and sync project.The project 'AccurateCalculator' may be using a version of Gradle that does not contain the method.
-Open Gradle wrapper file.The build file may be missing a Gradle plugin. Apply Gradle plugin

该项目的build.grade文件中有以下代码:

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

allprojects {
    repositories {
        jcenter()
    }
}

该模块的build.gradle包含以下代码:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 17
    buildToolsVersion "25.0.2"

    defaultConfig {
        applicationId "calculator.app"
        minSdkVersion 14
        targetSdkVersion 17
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile files('libs/achartengine.jar')
    compile files('libs/arity-2.1.6.jar')
    compile files('libs/ejml-0.21.jar')
    compile files('libs/slider.jar')
}
2个回答

4

正如警告所示,将插件升级到2.3.2版本应该解决此问题:

classpath 'com.android.tools.build:gradle:2.3.2'

0

对于那些遇到这个问题并且无法通过更改gradle文件来解决的人:

在我的MAC电脑格式化之后,我也遇到了这个问题。对我来说解决方法是将操作系统语言更改为英文。我建议尝试一下。

更改操作系统语言(MAC)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接