Android Gradle Build Error:(9, 0) Gradle Dsl Method Not Found: 'Compile()'

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.+'
}

Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.

I have tried applying every single gradle plugin they link me to in that link on the bottom, yet same issue, so I conclude that the first error is the cause.

Correct.

Here is the build.gradle file for AlexTest (the project directory):

You will notice that this file contains a code comment:

    // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

Remove the compile 'com.google.android.gms:play-services:6.1.11' line from that file. Leave the compile 'com.google.android.gms:play-services:6.1.+' that you have in the other build.gradle file.

The dependencies closure in buildscript is for Gradle plugins only. The top-level dependencies closure, found in the module's build.gradle file, is for application dependencies.

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+'

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'
...
}

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.

Getting Error Gradle DSL method not found: 'compile()' when Syncing Build.Gradle

In almost all cases, your dependencies should be put into the individual module's build.gradle files rather than at the top most level build.gradle file. In your case, that means the dependency should be added to the app module's build.gradle file:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:18.0.+"
}

And you should remove the entire allprojects part of the top level build.gradle.

Gradle DSL method not found: 'compile()' using Twitter sdk

First build.gradle

 apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.twitter.ratz.william.test"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'
compile 'com.twitter.sdk.android:twitter:3.1.1'
compile 'com.twitter.sdk.android:twitter-mopub:3.1.1'
testCompile 'junit:junit:4.12'
}

Second build.gradle

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()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Gradle DSL method not found: 'compileSdkVersion()' after importing a module into the project

Error:(16, 0) Gradle DSL method not found: 'compileSdkVersion()'

You can't use this syntax in the top-level file:

ext {
compileSdkVersion 25
buildToolsVersion "25.0.2"
minSdkVersion 16
targetSdkVersion 25
}

Instead you can use this syntax (pay attention to = )

ext {
// The following are only a few examples of the types of properties you can define.
compileSdkVersion = 25
buildToolsVersion = "26.0.1"
...
}


Related Topics



Leave a reply



Submit