android - buildTypes Android Studio错误

标签 android android-studio gradle

我的项目gradle文件中出现此错误:

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



我目前正在使用Android Studio 1.1.0,compileSdkVersion 22,buildToolsVersion 22.0.0和targetSdkVersion22。使用compileSdkVersion 21似乎可以解决此问题。有小费吗?

编辑:
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.xxxx.yyyy"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

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

最佳答案

我开始了一个新的新项目,并且看到它运行良好,所以我只复制了build.gradle文件。实际上,唯一的区别是缺少compileOptions部分。我删除了该部分,同步gradle,再次插入了该部分,再次同步gradle,现在可以使用了!

关于android - buildTypes Android Studio错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29186565/

相关文章:

android - 如何使用 build.gradle 创建 aar 文件

android - 在 Android Studio 中找不到默认 Activity

java - 导入模块库后 Gradle 错误

android-studio - Android Studio 3.1 Logcat 前缀并不总是显示和破坏漂亮的记录器

安卓工作室 : How can I get the aligned signed release APK?

gradle - 使用 'Apply'在Gradle中添加特定的插件版本

移动操作系统、Android 和 ipad 上的 Javascript

java - Android 中完全控制的线程队列

android - BlackBerry 的 Android WebView Component 是什么?

java - Allure @Step 未出现在 allure 报告中(Selenide TestNG Gradle Allure)