Dependencies' Cannot Be Applied to '(Groovy.Lang.Closure)'

dependencies' cannot be applied to '(groovy.lang.Closure)'

Based on what Android Studio generates, you need to have a top-level project file build.gradle, and another for your app build.gradle.

Top-level:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
maven { url 'http://download.crashlytics.com/maven' }
}
}

Application level:

apply plugin: 'com.android.application'
apply plugin: 'crashlytics'

android{
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {
debuggable rootProject.prodDebug
proguardFile 'proguard.cfg'
}
}

packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
} `

dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':FRNDzTER_core')
compile project(':cropper')
compile project(':stickyListHeaders')
compile "com.nostra13.universalimageloader:universal-image- l loader:${rootProject.universalImageLoaderVersion}"
compile "com.google.android.gms:play- services:${rootProject.googlePlayServicesVersion}"
compile " "de.keyboardsurfer.android.widget:crouton:${rootProject.croutonVersion}"
compile "com.nineoldandroids:library:${rootProject.nineoldandroidsVersion}"
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.crashlytics.android:crashlytics:1.+'
}

But even without all that, your problem is that you have a dependencies within your android plugin config.

android {
dependencies {
}
}

remove that empty dependencies block.

EDIT: I also started getting this error with the latest Android Studio, all I had to do was add a newer version of the Gradle plugin, and compileSdkVersion 22.

buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'

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

allprojects {
repositories {
jcenter()
mavenCentral()
}
}

IntelliJ IDEA and Gradle - Cannot be applied to '(groovy.lang.Closure)'

For anyone looking for a similar fix, this boiled down to the type of the module. My module was defined in my .iml file as

type="WEB_MODULE"

I created a new Gradle module and pasted in the same contents, deleted the original, renamed the new module to have the same name as the old one, and everything worked fine. When I diffed the results the only change was that the .iml file now said:

type="JAVA_MODULE"

So there's the answer, seemingly. Change your module from "web" to "java".

buildTypes cannot be applied to groovy.lang.Closure

For me the problem was not solved by applying the above solution. Instead I had to go to the settings within Android Studio and select "Use gradle wrapper":

In Android Studio select:
File\Settings\Build, Execution, Deployment\Build tools\Gradle

(Mac Users: Android Studio\Preferences...\Build, Execution, Deployment\Build tools\Gradle )

Mark: Use default gradle wrapper (default)

This removed all 'cannot be applied to '(groovy.lang.Closure') warnings in the build files.

Gradle: 'buildTypes' cannot be applied to groovy.lang.Closure

Answer:

For some reason, I found that cutting (Ctrl + X) the buildTypes section and pasting it below the productFlavours section, then moving it back to where it was seemed to solve the issue.



Related Topics



Leave a reply



Submit