简体   繁体   English

错误:未找到 Gradle DSL 方法:'compile()'

[英]ERROR: Gradle DSL method not found: 'compile()'

I'm trying to use yelp-fusion-android library.我正在尝试使用 yelp-fusion-android 库。 I tried updating the gradle but no luck.我尝试更新 gradle 但没有运气。

I am getting this error:我收到此错误:

ERROR: Gradle DSL method not found: 'compile()'
Possible causes:
The project 'testProject' 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

Here is build.gradle:这是 build.gradle:

buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

Your problem is here compile 'io.github.ranga543:yelp-fusion-client:0.1.4'你的问题在这里 compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

Compile is deprecated use "Implementation" instead不推荐使用编译,而是使用“实现”

and you are placing it in the wrong gradle there are 2 gradle files please note this warning // NOTE: Do not place your application dependencies here;并且您将其放置在错误的 gradle 中有 2 个 gradle 文件请注意此警告 // 注意:不要将您的应用程序依赖项放在这里; they belong // in the individual module build.gradle files它们属于 // 在单个模块 build.gradle 文件中

Place below dependency in app module instead of main project gradle.将以下依赖项放在应用程序模块中,而不是主项目 gradle。

compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

and replace compile with Implementation.并用实现替换编译。 eg (In app module)例如(在应用程序模块中)

Implementation 'io.github.ranga543:yelp-fusion-client:0.1.4'

Remove this line from the top-level file:顶层文件中删除这一行:

//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

In the app/build.gradle file you can add the same dependency:app/build.gradle文件中,您可以添加相同的依赖项:

dependencies {
    ...
    implementation 'io.github.ranga543:yelp-fusion-client:0.1.5'
    ...
}

dependencies section inside buildscript is not for module dependencies. buildscript中的dependencies项部分不适用于模块依赖项。 Hence.因此。 move out compile 'io.github.ranga543:yelp-fusion-client:0.1.4' from this section and create top level dependencies block and put it there as below:从本节中移出compile 'io.github.ranga543:yelp-fusion-client:0.1.4'并创建顶级依赖项块并将其放在那里,如下所示:

buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.1'
    classpath 'com.google.gms:google-services:4.3.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

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

dependencies {
    compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
    }

Also, if you have got submodule then you can add this dependency to the sub-module.此外,如果您有子模块,那么您可以将此依赖项添加到子模块中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android gradle错误:(69,0)未找到Gradle DSL方法:“ compile()” - Android gradle Error:(69, 0) Gradle DSL method not found: 'compile()' Android Gradle构建错误:(65,0)未找到Gradle DSL方法:“ compile()” - Android gradle build Error:(65, 0) Gradle DSL method not found: 'compile()' Gradle 错误:找不到 Gradle DSL 方法:'executeWithoutThrowingTaskFailure()' - Gradle Error:Gradle DSL method not found: 'executeWithoutThrowingTaskFailure()' 错误:未找到 Gradle DSL 方法:“实施()” - ERROR: Gradle DSL method not found: 'imlementation()' 错误:(9,0):'google()'未找到Gradle DSL方法 - Error:(9, 0): 'google()' Gradle DSL method not found Neokree导航抽屉:未找到Gradle DSL方法:'compile()' - Neokree Navigation drawer: Gradle DSL method not found: 'compile()' android错误:Gradle同步失败:未找到Gradle DSL方法:'classpath()' - android error : Gradle sync failed: Gradle DSL method not found: 'classpath()' 找不到Gradle DSL方法:storeFile() - Gradle DSL method not found: storeFile() 找不到Gradle DSL方法:“ compileOptions()” - Gradle DSL method not found:'compileOptions()' 找不到 Gradle DSL 方法:'ooapply()' - Gradle DSL method not found: 'ooapply()'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM