Как исправить «ОШИБКА: метод Gradle DSL не найден» в Android Studio 3.3 - PullRequest
1 голос
/ 26 апреля 2019

Я только что установил 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
    }
}

Ответы [ 2 ]

1 голос
/ 06 мая 2019

Если у вас турецкая рабочая станция, измените build.gradle:

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

0 голосов
/ 27 апреля 2019
  1. application / build.gradle должно быть в этой строке (см. Версию плагина gradle как 3.4.0)

Файл сборки верхнего уровня, в который можно добавить параметры конфигурации, общие для всех подпроектов / модулей.

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
}
  1. application / gradle / wrapper / gradle-wrapper.properties должны быть в этой строке (см. Версию gradle как 5.1.1)

вс 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
  1. Нет проблем с вашим application/app/build.gradle (который вы разместили на github)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...