我正在尝试使用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
}
答案 0 :(得分:0)
您的问题在这里 编译'io.github.ranga543:yelp-fusion-client:0.1.4'
不推荐使用编译,而是使用“实现”
,而您将其放置在错误的gradle中,则有2个gradle文件 请注意此警告 //注意:请勿在此处放置应用程序依赖项;他们属于 //在各个模块的build.gradle文件中
答案 1 :(得分:0)
在依赖项下放置在 app 模块中,而不是在主项目gradle中放置
。compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
并用Implementation代替compile。 例如(在 app 模块中)
Implementation 'io.github.ranga543:yelp-fusion-client:0.1.4'
答案 2 :(得分:0)
从文件中删除这一行:
//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
在app/build.gradle
文件中,您可以添加相同的依赖项:
dependencies {
...
implementation 'io.github.ranga543:yelp-fusion-client:0.1.5'
...
}
答案 3 :(得分:0)
dependencies
中的 buildscript
部分不适用于模块依赖性。因此。从本节中移出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'
}
此外,如果您有子模块,则可以将此依赖项添加到子模块中。