bsikriwal
bsikriwal

Reputation: 206

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

I am trying to integrate google play billing library with my android application and when I try to add this dependency (compile 'com.android.billingclient:billing:1.0') in the app module's build.gradle file. I get the following error:

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

Can anyone help?

Thanks already.

Upvotes: 5

Views: 3719

Answers (2)

Hardik Bambhania
Hardik Bambhania

Reputation: 1792

Below dependency should not be added in top level gradle

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

Add it in app module gradle.

And compile keyword is deprecated now you can use below new version

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

Upvotes: 1

Ashish
Ashish

Reputation: 6919

Go to Build.gradle(Module:App) :

image

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

Upvotes: 4

Related Questions