Gradle: 'buildTypes' cannot be applied to groovy.lang.Closure [duplicate]

最后都变了- 提交于 2019-12-08 15:15:10

问题


After changing targetSdkVersion and compileSdkVersion to 22, and changing my buildToolsVersion to 22.0.1, I keep getting the following error:

'buildTypes' cannot be applied to '(groovy.lang.Closure< com.android.build.gradle.internal.dsl.BuildType>)'

I looked at my build.gradle file and tried to look for anything that could be an error:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "********"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 17
        versionName "1.5-beta"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        freeFlavour {
            applicationId "********"
        }
        paidFlavour {
            applicationId "********"
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
}

回答1:


Answer:

For some reason, I found that cutting (Ctrl + X) the buildTypes section and pasting it below the productFlavours section, then moving it back to where it was seemed to solve the issue.



来源:https://stackoverflow.com/questions/29549954/gradle-buildtypes-cannot-be-applied-to-groovy-lang-closure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!