Reputation: 1405
I am new to Gradle build tool. I want to create constant OPEN_WEATHER_MAP_API_KEY in android app but I am getting following error
build.gradle
`apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.android.sunshine.app"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.all { variant ->
variant.buildConfigField "String", "OPEN_WEATHER_MAP_API_KEY", "1"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}`
I tried multiple things but can not able to resolve it.
Upvotes: 1
Views: 253
Reputation: 1007534
Replace:
variant.buildConfigField "String", "OPEN_WEATHER_MAP_API_KEY", "1"
with:
variant.buildConfigField "String", "OPEN_WEATHER_MAP_API_KEY", '"1"'
The String
needs to be quoted. If the field was an int
, you could have left it unquoted.
Upvotes: 2