![](/img/trans.png)
[英]Android gradle Error:(69, 0) Gradle DSL method not found: '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.