buildTypes cannot be applied to groovy.lang.Closure

前端 未结 19 2252
故里飘歌
故里飘歌 2020-11-27 11:31

I\'m getting this warning in my project gradle file:

Warning:(16, 5) \'buildTypes\' cannot be applied to \'(groovy.lang.Closure< com.android.build.

19条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 12:21

    In my case my buildTypes section was above my productFlavors section. Interchanging their positions got rid of the warning:

    BEFORE:

    buildTypes {
    
            debug {
                minifyEnabled false
                shrinkResources false
                ...//etc
            }
     }
    
     productFlavors {
        demo {
            ...//etc
        }
     }
    

    AFTER:

     productFlavors {
        demo {
            ...//etc
        }
     }    
    
     buildTypes {
    
            debug {
                minifyEnabled false
                shrinkResources false
                ...//etc
            }
     }
    

    I am using Android Studio 2.1.2 with the following config at the top of my android section:

    android {
        compileSdkVersion 24
        buildToolsVersion "23.0.3"
    
        defaultConfig {
            applicationId "com.xyz.abc"
            minSdkVersion 14
            targetSdkVersion 24
            //..etc
    

提交回复
热议问题