簡體   English   中英

錯誤:未找到 Gradle DSL 方法:'compile()'

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

我正在嘗試使用 yelp-fusion-android 庫。 我嘗試更新 gradle 但沒有運氣。

我收到此錯誤:

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

這是 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
}

你的問題在這里 compile 'io.github.ranga543:yelp-fusion-client:0.1.4'

不推薦使用編譯,而是使用“實現”

並且您將其放置在錯誤的 gradle 中有 2 個 gradle 文件請注意此警告 // 注意:不要將您的應用程序依賴項放在這里; 它們屬於 // 在單個模塊 build.gradle 文件中

將以下依賴項放在應用程序模塊中,而不是主項目 gradle。

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

並用實現替換編譯。 例如(在應用程序模塊中)

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

頂層文件中刪除這一行:

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

app/build.gradle文件中,您可以添加相同的依賴項:

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

buildscript中的dependencies項部分不適用於模塊依賴項。 因此。 從本節中移出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'
    }

此外,如果您有子模塊,那么您可以將此依賴項添加到子模塊中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM