Ash*_*lli 120 groovy android gradle
我无法修复此错误:
dependencies cannot be applied to '(groovy.lang.Closure)
Run Code Online (Sandbox Code Playgroud)
这是我的gradle文件:
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
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-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.+'
}
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'
}
}
dependencies {
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
abortOnError false
}
}
Run Code Online (Sandbox Code Playgroud)
cod*_*uss 247
您可以转到"首选项"并选择"使用默认gradle包装器",然后重建项目.它对我很有用:

Mar*_*zon 37
去
视窗
文件 - >设置 - >构建,执行,部署 - >构建工具 - > Gradle
苹果电脑
首选项 - >构建,执行,部署 - >构建工具 - > Gradle
并选择使用默认gradle包装器
Epi*_*rce 22
根据Android Studio生成的内容,您需要拥有一个顶级项目文件build.gradle,另一个适用于您的应用build.gradle.
顶层:
// 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' }
}
}
Run Code Online (Sandbox Code Playgroud)
申请级别:
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.+'
}
Run Code Online (Sandbox Code Playgroud)
但即使没有这一切,你的问题是dependencies你的android插件配置中有一个.
android {
dependencies {
}
}
Run Code Online (Sandbox Code Playgroud)
删除那个空dependencies块.
编辑:我也开始使用最新的Android Studio收到此错误,我所要做的就是添加更新版本的Gradle插件和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()
}
}
Run Code Online (Sandbox Code Playgroud)
Ars*_*rst 18
我的问题是整个build.setting文件都被cannot be applied to '(groovy.lang.Closure)'警告消息占用,而不是发生在任何特定变量上.
我尝试过其他人提供的所有解决方案,但它们都不适合我.我结束了这些步骤,然后它就像一个魅力.如果您遇到同样的问题,请尝试一下.
yourproject/gradle/wrapper/gradle-wrapper.properties.编辑内容以更新gradle分发版本,如下图所示,然后保存.yourproject/.gradle.Sync project with gradle files,然后你很高兴.And*_*rey 18
如果您已经使用"默认gradle包装器"并且它没有帮助:
In Menu click: File -> Invalidate Caches / Restart...
Run Code Online (Sandbox Code Playgroud)
如果它也没有帮助尝试分两步:
1) Delete ".gradle" folder (and "build" folder if you have it already)
2) In Menu click: File -> Invalidate Caches / Restart...
Run Code Online (Sandbox Code Playgroud)
重新启动后警告应该消失.
(对我而言,它适用于Android Studio和IntelliJ Idea)
| 归档时间: |
|
| 查看次数: |
55206 次 |
| 最近记录: |