简体   繁体   English

buildTypes不起作用build.gradle Android Studio

[英]buildTypes not working build.gradle Android Studio

I am new to Android studio and I need to add: 我是Android Studio的新手,我需要添加:

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        debuggable true
    }
}

in my build.gradle Android Studio, but getting error: 在我的build.gradle Android Studio中,但出现错误:

Gradle DSL method not found:'buildTypes()' 找不到Gradle DSL方法:“ buildTypes()”

尝试从“文件->项目结构”中配置buildTypes并选择您的模块,您可以在右侧面板上轻松配置所有内容。

are you sure that your build file is set up correctly? 您确定构建文件设置正确吗?

The buildTypes have to be in the android closure. buildTypes必须在android闭包中。 It should look something like this 它应该看起来像这样

note: this is just a example you can't just copy and paste this 注意:这只是一个示例,您不能仅复制并粘贴此示例

android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.your.package"
    minSdkVersion 19
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

Hope this is of use for you 希望这对您有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM