Error: (21, 0) Gradle DSL method not found:

This is the full text of the error: -

Error: (21, 0) Gradle DSL method not found: 'buildConfigField ()'

Possible reasons:

The Sunshine2 project may use a version from Gradle that does not contain a method. Gradle Settings Build file may be missing the Gradle plugin. Submit Gradle Plugin Expression

I am using Gradle 2.4 with Android Studio 1.4. I do not know what causes the problem or how to fix it. Help a little please.

+6
source share
2 answers

There was no comma in the line of code calling BuildConfig:

buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY' 'MyOpenWeatherAPIKey' } 

Now it reads as follows:

 buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'MyOpenWeatherAPIKey' } 
+3
source

You might be missing a parenthesis while copying is pasted into MyOpenWeatherAPIKey

It initially looks like

 buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherAPIKey } 

After copying MyOpenWeatherAPIKey from https://home.openweathermap.org/api_keys he needs

 buildTypes.each { it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' } 
0
source

All Articles