I had this gradle error
Error:(21, 0) Gradle DSL method not found: 'buildConfigField()' Possible causes:
<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>
my build.gradle code is here
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'
}
anyone having any idea? thanks in advance
This is a very annoying how gradle works issue. For reference:
buildConfigField("String", "API_BASE_URL", "https://x.x.x.com/v2/")
Will result in:
It's necessary to apply escaped quotes like:
buildConfigField("String", "API_BASE_URL", "\"https://x.x.x.com/v2/\"")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With