构建脚本错误,不支持的摇篮DSL方法发现:“发布()'!不支持、摇篮、脚本、错误

2023-09-08 09:21:50 作者:不要以为世界皆你妈

我使用的是Android工作室0.50版本的Gradle和1.11,在所有的gradle我的包装。我有3个模块和下面是的build.gradle文件。

I am using Android studio 0.50 release and gradle 1.11-all in my gradle wrapper. I have 3 modules and following are the build.gradle files.

模块1

apply plugin: 'android'
apply plugin: 'android-test'

android {
compileSdkVersion 19
buildToolsVersion '19.0.1'

packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

sourceSets {
    androidTest.setRoot('src/test')

}
}

模块2

apply plugin: 'android-library'
apply plugin: 'android-test'

android {
compileSdkVersion 19
buildToolsVersion "19.0.1"

defaultConfig {
    minSdkVersion 10
    targetSdkVersion 16
    versionCode 1
    versionName "1.0"
}
release {
    runProguard false
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
sourceSets {
    instrumentTest.setRoot('src/test')
}
}

项目的根build.gralde

buildscript {
repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
    classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
    classpath 'com.nineoldandroids:library:2.4.0'
}
}

allprojects {
repositories {
    mavenCentral()
    mavenLocal()
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
}
}

对不起,长的问题,我试图拆除包装选项,并在this线程,但没有运气。我缺少什么?

Sorry for the long question, I tried removing the packaging options and mentioned in this thread, but no luck. Am I missing anything?

推荐答案

按照迁移到摇篮0.9指南(如摇篮0.9需要为Android 0.5.0工作室):

Per the Migrating to Gradle 0.9 guide (as Gradle 0.9 is required for Android Studio 0.5.0):

对于库项目的DSL现在是相同的应用项目。这意味着你可以创建更多的生成类型,并创建味道。

The DSL for the library projects is now the same as for the application projects. This means you can create more build types, and create flavors.

因此​​

android {
    debug {
    }
    release {
    }
    debugSigningConfig {
    }
}

变为

android {
    buildTypes {
        debug {
        }
        release {
        }
    }
    signingConfigs {
        debug {
        }
    }
}