本文介绍了如何解决“错误:未找到Gradle DSL方法";在Android Studio 3.3上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚在计算机上安装了Android Studio 3.3和Java,当我立即打开一个新项目时,出现此错误.
I just installed Android Studio 3.3 and Java on my computer, when I opened a new project instantly I got this error.
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以查看其版本.)
When I tried to update manually, I downloaded gradle 5.4.0 and installed manually. (Also I checked on cmd to see its version.)
然后我改变了
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我仍然遇到相同的错误.我该如何解决?
These code to gradle:5.4.0 I got still same error. How can I fixed it?
}
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
}
}
推荐答案
- application/build.gradle 应该在这行上(请参阅gradle插件版本为3.4.0)
- application/build.gradle shall be on this line(see gradle plugin version as 3.4.0)
顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项.
Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.20'
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
}
}
allprojects {
repositories {
google()
jcenter()
//maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
- application/gradle/wrapper/gradle-wrapper.properties应该在这行上(请参阅gradle版本为5.1.1)
Sun Mar 24 01:41:54 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
- 您的
application/app/build.gradle
(您在github上发布的)没有问题
- No issue with your
application/app/build.gradle
(which you posted on github)
这篇关于如何解决“错误:未找到Gradle DSL方法";在Android Studio 3.3上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!