Gradle DSL method not found: 'compile()'
As the note of your project's build.gradle
file suggests:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Remove the 2 compile statements in that gradle file:
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
And then make your other (module's) build.gradle
dependencies look like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.+'
}
How to fix an error Gradle DSL method not found: 'compile()'?
Go to Build.gradle(Module:App) :
dependencies {
implementation 'com.android.billingclient:billing:1.0'
}
ERROR: Gradle DSL method not found: 'compile()'
Remove this line from the top-level file:
//compile 'io.github.ranga543:yelp-fusion-client:0.1.4'
In the app/build.gradle
file you can add the same dependency:
dependencies {
...
implementation 'io.github.ranga543:yelp-fusion-client:0.1.5'
...
}
Error: Gradle DSL method not found: compile()
Move this line in different lines:
//TV & Radio
compile "com.android.support:cardview-v7:$supportlib_version" compile "com.android.support:appcompat-v7:$supportlib_version" compile "com.android.support:recyclerview-v7:$supportlib_version" compile "com.android.support:design:$supportlib_version" compile "com.android.support:support-v4:$supportlib_version" compile "com.android.support:support-core-utils:$supportlib_version" compile "com.android.support:support-media-compat:$supportlib_version" compile "com.google.android.gms:play-services-gcm:$gps_version" compile "com.google.android.gms:play-services-ads:$gps_version" compile "com.google.android.gms:play-services-maps:$gps_version" compile 'com.google.maps.android:android-maps-utils:0.5+'
You can't use compile
in this way.
Use this:
compile "com.android.support:cardview-v7:$supportlib_version"
compile "com.android.support:appcompat-v7:$supportlib_version"
compile "com.android.support:recyclerview-v7:$supportlib_version"
compile "com.android.support:design:$supportlib_version"
compile "com.android.support:support-v4:$supportlib_version"
compile "com.android.support:support-core-utils:$supportlib_version"
compile "com.android.support:support-media-compat:$supportlib_version"
compile "com.google.android.gms:play-services-gcm:$gps_version"
compile "com.google.android.gms:play-services-ads:$gps_version"
compile "com.google.android.gms:play-services-maps:$gps_version"
compile 'com.google.maps.android:android-maps-utils:0.5+'
Gradle DSL method not found: 'implementation()'
To use the DSL implementation()
you have to use:
- The updated gradle plugin for Android 3.0.0
- The gradle version 3.4 or later
Then in your build.gradle
you have to use:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
}
}
In your gradle-wrapper.properties
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
More detailed info here.
Gradle DSL method not found: 'compile() The project 'android' may be using a version of Gradle that does not contain the method
The problem is inside the dependencies closure: You can't write multiple compile statements in one line. Just write each compile statement in a separate line, than it will work.
I think it's a bug with auto-formatting when you use variables for the dependency versions and therefore wrap the dependencies in double quotes instead of single quotes.
Android Studio Gradle DSL method not found: 'compile()'
Your build gradle tools seem too old, change the following line in the root build.gradle:
classpath 'com.android.tools.build:gradle:1.5.0'
to
classpath 'com.android.tools.build:gradle:2.3.3'
And don't forget to add google maven to your build.gradle too:
maven { url "https://maven.google.com" }
This is because all support library are moved to maven as in the release note at https://developer.android.com/topic/libraries/support-library/revisions.html:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
So then your root build.gradle will be something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle dsl method not found 'compile()' Error:(10,0)
so according to the documentations i add theses lines into the build.gradle of my project
Please note the comments in that file:
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
I do not know what "documentations" that you read that told you to put these things in the project-level build.gradle
file. Please consider providing links, so that we can get that material fixed.
To get past this problem, remove the changes that you made to this file. Then, add those dependencies to the module's build.gradle
file (e.g., app/build.gradle
in a typical Android Studio project).
Related Topics
How to Send Broadcast from One App to Another App
What's Wrong with Debugging in Eclipse on Android
Incompatible Plugins for Android-Apt After Upgrading to Android Studio 2.3
Android.Database.Cursorindexoutofboundsexception: Index 0 Requested, with a Size of 0
Pathpattern to Match File Extension Does Not Work If a Period Exists Elsewhere in the File Name
Calculate Text Size According to Width of Text Area
Detect Touch Event on a View When Dragged Over from Other View
How to Retrieve the Logged in Google Account on Android Phones
How to Use the Same Keystore File to Sign Two Different Applications
Proguard: Can't Find Referenced Class Com.Google.Android.Gms.R
Android O - Old Start Foreground Service Still Working
Android Runonuithread Explanation
Launch Skype from an App Programmatically & Pass Number - Android
Android Studio Gradle Dsl Method Not Found: 'Android()' -- Error(17,0)
Findfragmentbyid for Supportmapfragment Returns Null in Android Studio
Differencebetween Activity and Context