我正在尝试在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')
}
有人可以帮忙吗?
提前致谢。
答案 0 :(得分:3)
如警告所示,将插件升级到2.3.2
应该可以解决问题:
classpath 'com.android.tools.build:gradle:2.3.2'
答案 1 :(得分:0)
对于那些遇到此问题并且无法通过更改gradle文件来解决此问题的人:
格式化我的MAC后,我遇到了这个问题。对我来说,解决方法是将OS语言改回英语。我建议尝试一下。