我遇到了这个 gradle 错误
错误:(21, 0) Gradle DSL 方法未找到:'buildConfigField()' 可能的原因:
<ul><li>The project 'Sunshine' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
我的 build.gradle 代码在这里
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.boxerrebellion.sunshine.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
}
有人知道吗? 在此先感谢
最佳答案
buildConfigField
定义如下
void buildConfigField(String type, String name, String value)
它需要一个类型、字段的名称和值。如果有前两个,而不是第三个。您可以阅读更多信息 here
关于android - Gradle DSL 方法未找到 : 'buildConfigField()' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36870618/