找不到Gradle DSl方法:'buildConfigField()'可能的原因

时间:2017-07-22 06:03:33

标签: android

美好的一天,我的应用程序出现问题,Gradle项目同步失败

Error:(22, 0) Gradle DSL method not found: 'buildConfigField()'
Possible causes:<ul><li>The project 'Weather-master' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
<a href="fixGradleElements">Upgrade plugin to version 2.3.3 and sync project</a></li><li>The project 'Weather-master' may be using a version of Gradle that does not contain the method.
<a href="open.wrapper.file">Open Gradle wrapper file</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'realm-android'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.ccjeng.weather"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 10
        versionName "1.4.0.032617W"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        buildTypes.each {
            buildConfigField "String", "DARK_SKY_KEY", '"b35f87cc72b82388ed9276e41fd55dd0"'
            buildConfigField "String", "FLICKR_API_KEY", '"b35f87cc72b82388ed9276e41fd55dd0"'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'joda-time:joda-time:2.9.4'
    compile('com.mikepenz:aboutlibraries:5.8.1@aar') { transitive = true }
    compile 'com.github.bumptech.glide:glide:3.7.0'
    // compile 'com.android.support:support-v4:24.2.1'
}

我已经将Gradle升级到v2.3.3,但同样的问题,gradle-apt-plugin出了什么问题?

0 个答案:

没有答案