如何修复Android Studio 3.3上的“ERROR:Gradle DSL method not found”

问题描述 投票:-1回答:2

我刚刚在我的计算机上安装了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
    }
}  

这些代码用于gradle: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
    }
}
android gradle android-gradle
2个回答
0
投票
  1. application / build.gradle应在此行上(请参阅gradle插件版本为3.4.0) //顶级构建文件,您可以在其中添加所有子项目/模块共有的配置选项。 buildscript {\ text.kotlin_version ='1.3.20'存储库{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(类型:删除){delete rootProject.buildDir}
  2. application / gradle / wrapper / gradle-wrapper.properties应在此行上(参见gradle version as 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
  3. 您的应用程序/ app / build.gradle(您在github上发布的)没有问题

1
投票

如果您是土耳其工作站,请更改build.gradle:

testImplementation - > testİmplementation androidTestImplementation - > androidTestİmplementation androidTestImplementation - > androidTestİmplementation

© www.soinside.com 2019 - 2024. All rights reserved.