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

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.

Go to Build.gradle(Module:App) :
dependencies {
implementation 'com.android.billingclient:billing:1.0'
}

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'

Related

Adding Gradle Dependency Breaks Gradle Build

I added the stripe sdk to my kotlin app and can no longer build my application.
Addition to grade file:
implementation 'com.stripe:stripe-android:16.8.2'
Build error:
/Users/username/.gradle/caches/transforms-2/files-2.1/6fabb8e15860d0b2ea75a56e95ee9aa5/jetified-kotlin-stdlib-common-1.5.0.jar!/META-INF/kotlin-stdlib-common.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16.
Removing the stripe dependency fixes the issue. I also tried deleting the cache folder referenced in the error message and it was just recreated and the issue persisted.
The problem seems to be a mismatch between the kotlin library used in your project and the version of the plugin that is not compatible.
Upgrade your Gradle version by going to File>Project Structure.
Ps:(also try downgrading your kotlin version to one of the 1.4.x versions)
Another developer ran into this same issue and solved it by upgrading Gradle
I updated my gradle like this
// id 'org.jetbrains.kotlin.android.extensions' deprecated
id 'kotlin-parcelize'
and in project gradle add this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
so now it works.

Firebase Performance configuration fails with v1.1.2 when using implementation or api

I'm trying to upgrade my firebase-plugins dependency version to 1.1.2 which supports the Android Gradle Plugin version 3+, but the Gradle build configuration keeps failing unless I use compile which is deprecated. I'm using Play Services version 11.4.2 and and I have the firebase-perf dependency added like so which fails:
implementation "com.google.firebase:firebase-perf:$playServicesVersion"
The only way to fix it is to change the above implementation to compile. Has anyone found a solution to get around this? (Aside from downgrading to firebase-plugins version 1.1.0-alpha1?)
Here's the error message:
* What went wrong:
A problem occurred configuring project ':app'.
> To use the Firebase Performance Plugin, the Firebase Performance Monitoring SDK must be added to the app's build.gradle. Please add compile 'com.google.firebase:f
irebase-perf:VERSION_NUMBER_GREATER_THAN_OR_EQUAL_TO_11.0.4' to the app's build.gradle.
Edit: this has been fixed in firebase-plugins:1.1.3.
This error is because firebase-perf plugin is specifically looking for the presence of 'compile' configuration for com.google.firebase:firebase-perf SDK. If the SDK is not included in build.gradle at build time, there will be a run time crash later.
Android Studio 3.0 replaces 'compile' with 'implementation', the plugin code should instead checking 'implementation' configuration for firebase-perf SDK.
The workaround now is to continue using:
compile "com.google.firebase:firebase-perf:$playServicesVersion"
This will be fixed in the future firebase-plugins release.

Fastlane Android:Gradle sync failed: Could not find method screengrabVersion() for arguments

In Event Log,
Gradle sync failed: Could not find method screengrabVersion() for arguments [/Users/adminuser/Desktop/MyProject/version.properties] on project ':screengrab-lib' of type org.gradle.api.Project.
In Message Gradle Sync,
Error:(5, 0) Gradle DSL method not found: 'screengrabVersion()'
Possible causes:
The project 'MyProject' 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 2.3.3 and sync projectThe project 'MyProject' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
And nothing happen when I Click on "Upgrade plugin to version 2.3.3 and sync project"
I am using Android Studio version 2.3.3. Please help me on it.
After checking many hours I removed module dependency and put below Gradle dependency in App build.gradle file and It's working fine now,
androidTestCompile("tools.fastlane:screengrab:1.0.3", {
exclude group: 'com.android.support', module: 'support-annotations'
})

Error:(8, 0) Gradle DSL method not found: 'compile()'

How can I resolve this problem?
At first the problem was, I would like to use ActivityCompat class for ask permission. After it shown me the AdroidStudio, the class cannot be resolved to a type but, the Support Repository already installed...
I upgraded the AndroidStudio to 2.3 from 2.2 after show me:
Error:(8, 0) Gradle DSL method not found: 'compile()'
Currently here are the possible solutions by Android Studio:
'Sensors' 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 2.3.0 and sync project)
The project 'Sensors' may be using a version of Gradle that does not
contain the method. (Gradle settings)
The build file may be missing a Gradle plugin. (Apply Gradle plugin)
What is the right solution for this? I tried each but not resolve the problem.
Here is the dependencies of build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
compile "com.android.support:support-core-utils:25.2.0"
}
Move compile "com.android.support:support-core-utils:25.2.0" out of your top-level build.gradle file and into the module's build.gradle file (e.g., app/build.gradle) and its dependencies closure.

Android Gradle Sync error

Here is the problem that I get when trying to preform a Gradle sync, I am also running the latest android studio and have included the minifyEnabled
Error:(33, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'MLGSoundboard' may be using a version of Gradle that does not contain the method.
Gradle settings</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
It's just an issue with the project's gradle configuration. Just make a new project, and drag over everything except for the gradle files from the old project to the new one.

Categories

Resources