Comments (66)
You can also use the gradle.properties file tu define the constant MyOpenWeatherMapApiKey like this:
MyOpenWeatherMapApiKey = "abcdefg0123456"
And the project will sync without problem
from sunshine-version-2.
Yes, I know, but sadly when this get fixed, I will return to my anonymity.
Hahaha
from sunshine-version-2.
AMEN!
from sunshine-version-2.
Hi I have this problem with buildTypes.each
Error:(21, 0) Gradle DSL method not found: 'buildConfigField()'
Possible causes:
- The project 'Sunshine' may be using a version of Gradle that does not contain the method.
Gradle settings - The build file may be missing a Gradle plugin.
Apply Gradle plugin
And no, I am not missing a comma.
from sunshine-version-2.
Also this works:
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', ""abcdefg0123456""
from sunshine-version-2.
it helped !
from sunshine-version-2.
@tal32123 and others who are looking why defining MyOpenWeatherMapApiKey
in gradle.properties
doesn't work. The people at Udacity tells us to create gradle.properties
in .gradle
directory. But there is already in the normal project folder.(C/Users/.../Sunshine/gradle.properties)
. Put MyOpenWeatherMapApiKey="{YOURKEYHERE}"
there and replace {YOURKEYHERE}
with your key. and then leave the build.gradle
file as it is as they gave here at github. It will work
from sunshine-version-2.
@SiddharthVenu The reason why you shouldn't put your API key in your project's (C/Users/.../Sunshine/gradle.properties
) is because gradle recommends that file being checked in to version control. If you have your API key in that file, you shouldn't check it into version control. If you put your API key in your GLOBAL gradle.properties (~/.gradle/gradle.properties), it will be recognized by your project's build.gradle, but won't be checked into version control, which is really the goal here.
Does that make sense?
from sunshine-version-2.
@SiddharthVenu Uh oh! Shoot me an email ([email protected]) and I'll help you fix that!
from sunshine-version-2.
thanks for this solution , saved me hours of frustration.
from sunshine-version-2.
Thanks,
I really appreciate. The key you gave to me worked. Please can I just use
it for the practical sessions. Please
On Mon, Aug 1, 2016 at 10:14 PM, Ali Makhion [email protected]
wrote:
@Josephaguele https://github.com/Josephaguele this is the working code
you add these lines exactly as it is in build.gradle file inside the
android { } and this is my code
`apply plugin: 'com.android.application'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' , MyOpenWeatherMapApiKey
}}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
}
`and you must have a working api Key for the sunshine app to work and this
is my key " 3194b70c58f9e0bc45d2279c1696c587 " if you wish to use itand to must add your api key to the gradle.properties file located in
C:\Users\your username.gradle in windows and in your Home directory in mac
and here is the code in my gradle.properties fileorg.gradle.daemon=true
MyOpenWeatherMapApiKey="3194b70c58f9e0bc45d2279c1696c587"if you need any help i'm here
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#69 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATrEqSFZ5i5TaiKygsdNDwz37qdkbuyFks5qbmGlgaJpZM4GRqq-
.
from sunshine-version-2.
If you create (global) gradle.properties yourself, you should make a PROPERTIES FILE and not TEXT DOCUMENT (via notepad or something like that!)
Your gradle.properties should be like this:
and it must be in C:\Users[user name].gradle
It contains: MyOpenWeatherMapApiKey="xxxx1111xxxx"
Your build.gradle should be like this:
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey
}
...
from sunshine-version-2.
Thank you Cattalins, I also encountered this hiccup :)
from sunshine-version-2.
I agree Cattalins. Part of being a good coder is using comments to help clarify what the previous code means.
from sunshine-version-2.
That was starting to bother me and then I read this, so thank you Cattalins
from sunshine-version-2.
Wow, thank you for this post! This was something I also ran into that bothered me. Thanks for the information!
from sunshine-version-2.
I get stuck at the same situation. Thanks so much!!! cattallins
from sunshine-version-2.
@Cattalins Good catch and Thank you! I was searching errors using gradle as the error was not obvious.
from sunshine-version-2.
Thanks a lot Cattalins. That was very helpful and time saving.
from sunshine-version-2.
On the bright side, getting this fixed was also a learning experience and YOU get to say that you did it without this post! You're awesome!
from sunshine-version-2.
thank you Cattalins very much this helped me
from sunshine-version-2.
Thank you so much for your help :)
from sunshine-version-2.
that helped so much. Should've guessed to have done that when I saw the code it generated...
from sunshine-version-2.
Earlier,I quit the tutorial coz android studio wont let me run the app coz of this gradle quotes issue.
Thanks a lot!
from sunshine-version-2.
For some reason, my gradle built only works when I simulate through a virtual phone, not my galaxy.... Which was weird because it was compatible.
On Dec 26, 2015, at 11:01 PM, shrenuj [email protected] wrote:
I quit the tutorial coz android studio wont let me run the app coz of this gradle quotes issue.
—
Reply to this email directly or view it on GitHub.
from sunshine-version-2.
Good Catch..
from sunshine-version-2.
Thank u =)
from sunshine-version-2.
This link may be helpful http://stackoverflow.com/questions/33365650/cannot-resolve-symbol-c882c94be45fff9d16a1cf845fc16ec5
from sunshine-version-2.
This helps me a lot .. :)
from sunshine-version-2.
Thanks a lot
from sunshine-version-2.
This helped me a lot, thanks!!!
from sunshine-version-2.
I should have seen this before figuring out what the problem is. It would have saved a lot of time.
from sunshine-version-2.
Thank you so much for this post, i have spent last 2 hrs fixing this issue.
from sunshine-version-2.
Thanks a lot Cattalins
from sunshine-version-2.
buildTypes.each {
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', ""c882c94be45fff9d16a1cf845fc16ec5""
}
//me a funcionado!!!
from sunshine-version-2.
How does one use this code:
MyOpenWeatherMapApiKey = "abcdefg0123456"
it doesn't seem to work for me.
from sunshine-version-2.
from sunshine-version-2.
Thanks for your response, what is the point of this code then in the gradle properties file?:
MyOpenWeatherMapApiKey = "abcdefg0123456"
from sunshine-version-2.
Thanks!
I also met this problem!
I just add single quote...
from sunshine-version-2.
Thank you so Much
It solved the problem
from sunshine-version-2.
Thanks
from sunshine-version-2.
Thanks 💯
from sunshine-version-2.
Thanks! Spent about an hour looking for this fix!
from sunshine-version-2.
Thanks a lot!
from sunshine-version-2.
Thanks a lot. Got stuck here, kept applying " " and it still wouldn't render correctly in the build config. You saved me a lot of time.
from sunshine-version-2.
There's going to be a change coming that will make this process much more clear! Sorry for the current confusion. I agree, single quotes surrounding double quotes is very confusing.
from sunshine-version-2.
Thank you, you saved my day! Started pondering about this a fed days ago...
- However, I consider this a very educative catch. ;-)
from sunshine-version-2.
@halfjew22 But it does not recognize the variable if I put it in ~/.gradle
from sunshine-version-2.
I just encountered this, thank you for posting the solution.
from sunshine-version-2.
@Cattalins Your name has been engraved electronic stones of android history. You will not be forgotten.
from sunshine-version-2.
Thank you! That saved some headache.
from sunshine-version-2.
Why does it (OPEN_WEATHER_MAP_API_KEY) have to be written like this?
And what is the effect of having to code in the build area?
Please I need an answer to this questions
from sunshine-version-2.
@Josephaguele : naming OPEN_WEATHER_MAP_API_KEY like this will make no difference you can name it as you like but when you call it in your code "FetchWeatherTask" class BuildConfig.OPEN_WEATHER_MAP_API_KEY;
make sure to change the name here too
from sunshine-version-2.
@Cattalins i'm pretty sure this is not how it's done
buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherMapApiKey }
and MyOpenWeatherMapApiKey is like calling a variable you declared in gradle.propertie
MyOpenWeatherMapApiKey="3194b70c58f9e0bc45dfd2279c1696c587"
in gradle.properties file your .gradle folder in your home directory
when adding your api key in your build.gradle file you risk when using github t
from sunshine-version-2.
I tried coding it like everyone has said, but it hasn't worked for me yet because when I try to run the sunshine app, it still shows the run time error.
Is this not the correct code?
buildTypes.each{
it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', ""MyOpenWeatherMapApiKey""
}
Please can anyone help me out with this. And please must we have a correct and working API key before the Sunshine app will work?
from sunshine-version-2.
@Josephaguele this is the working code you add these lines exactly as it is in build.gradle file inside the android { } and this is my code
`apply plugin: 'com.android.application'
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' , MyOpenWeatherMapApiKey
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
}
`
you only add
buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY' , MyOpenWeatherMapApiKey }
in the correct place inside the android { } scope and don't change any thing else in this file and click sync now
and you must have a working api Key for the sunshine app to work and this is my key " 3194b70c58f9e0bc45d2279c1696c587 " if you wish to use it
and to must add your api key to the gradle.properties file located in C:\Users\your username.gradle in windows and in your Home directory in mac and here is the code in my gradle.properties file
org.gradle.daemon=true MyOpenWeatherMapApiKey="3194b70c58f9e0bc45d2279c1696c587"
if you need any help i'm here
from sunshine-version-2.
@Josephaguele it's yours 👍
from sunshine-version-2.
Thanks a lot. I really appreciate.
from sunshine-version-2.
Hi,
Please Is there any way I can get an updated explanation of Postal Code
Param. I really do not understand it .
I would be very grateful.
Thanks in anticipation.
On Sat, Aug 6, 2016 at 3:19 PM, Codenal [email protected] wrote:
Thanks a lot. I really appreciate.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#69 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATrEqTXqJ8wdvDtC2M-8aWBtYG4Xko5pks5qdJgKgaJpZM4GRqq-
.
from sunshine-version-2.
Please my android monitor screen is not showing the information as shown in the tutorial.
When I click the refresh button, this is what shows up on my screen.
I hope this will do well.
The last two lines, which is the InputManager is what shows up on my android studio monitor screen when I click the refresh button
from sunshine-version-2.
Thank's Cattalins
from sunshine-version-2.
Thank you
On Sat, Oct 8, 2016 at 5:55 AM, seiya021 [email protected] wrote:
Thank's Cattalins
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#69 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ATrEqe2qmkzYrY8xQnZA0DldBniDbm2Fks5qxyJfgaJpZM4GRqq-
.
from sunshine-version-2.
Thank you for help.
from sunshine-version-2.
ok, when changing the build.gradle file double check you inserted the code in the correct one. there's 2 here (Project and app), the code should be on the build.grade (app)
from sunshine-version-2.
from sunshine-version-2.
Thank you , that was helpful
from sunshine-version-2.
Related Issues (20)
- Issue in ForecastFragment FORECAST_COLUMNS and indices - Location_id column is missing HOT 1
- when i open it HOT 3
- UnsupportedMethodException
- Does not sync Automatically - works when refreshed or location change
- gradle version causes AS to fail build HOT 2
- No icon on the action bar!
- minSDK too low
- Refresh button not responding after adding code HOT 5
- addpreferencesfromresource and findPreference deprecated HOT 7
- error in mainActivity
- SettingsActivity didn't save location's value when I changed this HOT 1
- 2.01 add the Network Code HOT 1
- Adding Images to the App Resources$NotFoundException Resource ID #0xffffffff HOT 1
- request: Original SVG / Vector drawables HOT 1
- Listview only syncing when activity restarts HOT 1
- E/AbstractTracker: Can't create handler inside thread that has not called Looper.prepare()
- How to add a refresh button? HOT 1
- HOW TO CREATE FRAGMENT IN ANDROID STUDIO 3.0.1
- Installed API and updated with an error
- Could not find method implementation() for arguments [directory 'libs'] on project ':app'.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sunshine-version-2.