我刚刚在计算机上安装了Android Studio 3.3和Java,当我立即打开一个新项目时,出现此错误。
ERROR: Gradle DSL method not found: 'testImplementation()'
Possible causes:
The project 'My Application' 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 3.4.0 and sync project
The project 'My Application' may be using a version of Gradle that does not contain the method.
Gradle settings
The build file may be missing a Gradle plugin.
Apply Gradle plugin
当我尝试手动更新时,我下载了gradle 5.4.0并手动安装。 (我也检查了cmd以查看其版本。)
然后我改变了
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
这些要传递的代码:5.4.0我仍然遇到相同的错误。我该如何解决?
}
dependencies {
classpath 'com.android.tools.build:gradle:5.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
答案 0 :(得分:1)
如果您拥有土耳其语工作站,请在build.gradle中进行更改:
testImplementation
-> testİmplementation
androidTestImplementation
-> androidTestİmplementation
androidTestImplementation
-> androidTestİmplementation
答案 1 :(得分:0)
application / build.gradle应该在这行上(请参阅gradle插件版本3.4.0)
//顶层构建文件,您可以在其中添加所有子项目/模块共有的配置选项。
buildscript { ext.kotlin_version ='1.3.20' 储存库{ 谷歌() jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects { 储存库{ 谷歌() jcenter() // maven {url“ https://jitpack.io”} } }
任务清理(类型:删除){ 删除rootProject.buildDir }
application / gradle / wrapper / gradle-wrapper.properties应该在这行上(请参阅gradle版本为5.1.1)
distributionBase = GRADLE_USER_HOME distributionPath =包装器/ dists zipStoreBase = GRADLE_USER_HOME zipStorePath =包装器/ dists distributionUrl = https://services.gradle.org/distributions/gradle-5.1.1-all.zip
您的application / app / build.gradle(发布在github上)没有问题