Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

gradle

This is the full text of the error:-

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

Possible causes:

  • The project 'Sunshine2' 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
  • I'm using gradle 2.4 with Android Studio 1.4. I don't know what is causing the problem or how to fix it. A little help please.

    like image 680
    Alex Avatar asked Oct 20 '15 03:10

    Alex


    1 Answers

    The line of code calling the BuildConfig was missing a comma:

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

    It now reads like this:

    buildTypes.each {
            it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY',  'MyOpenWeatherAPIKey'
                }
    
    like image 172
    Alex Avatar answered Sep 28 '22 05:09

    Alex