如何修复错误 Gradle DSL 方法未找到:'compile()'?

How to fix an error Gradle DSL method not found: 'compile()'?

我正在尝试将 google Play 计费库与我的 android 应用程序集成,当我尝试在应用程序模块的 build.gradle 文件中添加此依赖项时 (compile 'com.android.billingclient:billing:1.0')。我收到以下错误:

ERROR: Gradle DSL method not found: 'compile()'

Possible causes:
The project 'work' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project

The project 'work' 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(模块:应用程序)

dependencies {
    implementation 'com.android.billingclient:billing:1.0'
}

不应在顶层添加以下依赖项gradle

compile 'com.android.billingclient:billing:1.0'

将其添加到应用程序模块中 gradle。

编译关键字已弃用,现在您可以在新版本以下使用

implementation 'com.android.billingclient:billing:1.0'