首页 > 解决方案 > 未找到 Gradle DSL 方法:'ooapply()'

问题描述

我在尝试解决链接 [StackOverflow Link] 之后的 google() 错误后收到此错误(错误:(6, 0) Gradle DSL method not found: 'google()'

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties 的代码

#Mon Jun 19 10:50:31 IST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

我的 Android Studio 版本是 3.3.2

以下是出现的完整错误。很少的帮助将非常有用。

Gradle DSL method not found: 'ooapply()'
Possible causes:
The project 'MyProject' 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.3.2 and sync project

The project 'MyProject' 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

我无法继续...

标签: javaandroidgradle

解决方案


它看起来像另一个build.gradle文件中的问题。您附加的文件可能是项目级 build.gradle

我猜问题出在模块级 build.gradle文件中。打开此文件并将ooapply替换为apply


推荐阅读