[英]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.