buildTypes 不能应用于 groovy.lang.Closure [英] buildTypes cannot be applied to groovy.lang.Closure
问题描述
我在我的项目 gradle 文件中收到此警告:
I'm getting this warning in my project gradle file:
警告:(16, 5) 'buildTypes' 不能应用于 '(groovy.lang.Closure< com.android.build.gradle.internal.dsl.BuildType>)'
Warning:(16, 5) 'buildTypes' cannot be applied to '(groovy.lang.Closure< com.android.build.gradle.internal.dsl.BuildType>)'
我的 buildTypes 部分是:
My buildTypes section is:
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
我目前使用的是 Android Studio 1.1.0、compileSdkVersion 22、buildToolsVersion 22.0.0 和 targetSdkVersion 22.我尝试回退到 21,但仍然收到警告.
I'm currently using Android Studio 1.1.0, compileSdkVersion 22, buildToolsVersion 22.0.0, and targetSdkVersion 22. I tried backing down to 21 but was still getting the warning.
是什么导致了这个警告&怎么修的?
What causes this warning & how is it fixed?
推荐答案
对我来说,应用上述解决方案并没有解决问题.相反,我必须转到 Android Studio 中的设置并选择使用 gradle 包装器":
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":
在 Android Studio 中选择:文件\设置\构建、执行、部署\构建工具\Gradle
In Android Studio select: File\Settings\Build, Execution, Deployment\Build tools\Gradle
(Mac 用户:Android Studio\Preferences...\Build、Execution、Deployment\Build tools\Gradle)
标记:使用默认的 gradle 包装器(默认)
这删除了构建文件中的所有不能应用于(groovy.lang.Closure")警告.
This removed all 'cannot be applied to '(groovy.lang.Closure') warnings in the build files.
这篇关于buildTypes 不能应用于 groovy.lang.Closure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!