2015-10-20 12 views
6

これはエラーの全文です: -エラー:(21、0)のGradleのDSL方法が見つかりません:

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

考えられる原因:

  • 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
  • 私はGradleの2.4を使用していますAndroid Studio 1.4。私は何が問題を引き起こしているのか、それを修正する方法を知らない。少し助けてください。

    +0

    あなたは、これはあなたがあなたを提供する必要がありhttp://stackoverflow.com/questions/23267365/cannot-add-buildconfigfield-in-productflavors – GMB

    +0

    チェックしているようすべきですbuild.scriptコンテンツ。あなたには文法上の問題があるようです。 – Stanislav

    +0

    GMB - カンマが足りませんでした。ありがとう。 – Alex

    答えて

    3

    BuildConfigにコンマが欠けていた呼び出すコードの行:

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

    それは次のように読み取ります

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

    コピーが

    あなたMyOpenWeatherAPIKeyを貼り付けながら、あなたは括弧が欠落する可能性があります

    最初にそれはのように見える

    buildTypes.each { 
        it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', MyOpenWeatherAPIKey 
    } 
    
    あなたが https://home.openweathermap.org/api_keysからあなたMyOpenWeatherAPIKeyをコピーした後

    それは

    buildTypes.each { 
        it.buildConfigField 'String', 'OPEN_WEATHER_MAP_API_KEY', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' 
    } 
    
    関連する問題