I'm working on Google's Udacity course for new Android Devs, and I've come into some trouble with the Gradle build and defining a constant in it. I've tried surrounding the field with multiple variations of ", ', and \'s that I say recommended online, but nothing seems to work. I was wondering how to format the line inside buildTypes.each, seen here?
buildTypes.each {
it.buildConfigField "String", "OPEN_WEATHER_MAP_API_KEY", **APICodeHere**
}
Here's the entirety of the code for the app's gradle build.
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.android.sunshine.app"
minSdkVersion 10
targetSdkVersion 21
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", **APICodeHere**
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
}
Thanks!!!
I am also taking this course and I had the same problem. The formatting that eventually worked for me is this:
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', "\"6df0...9ac\""
Paste your hexadecimal Open Weather API Key instead of the 6df0...9ac
above. Hope that helps!
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