Build script error, unsupported Gradle DSL method

2019-06-15 00:31发布

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.

Module 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')

}
}

Module 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')
}
}

project root 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/'
    }
}
}

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

3条回答
我只想做你的唯一
2楼-- · 2019-06-15 00:45

You didn't migrate Module 2 gradle. release must be inside buildTypes section in gradle 0.9 (which is default for studio 0.5). There is a migration guide here:

http://tools.android.com/tech-docs/new-build-system/migrating_to_09

查看更多
不美不萌又怎样
3楼-- · 2019-06-15 00:52

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

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.

Therefore

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

becomes

android {
    buildTypes {
        debug {
        }
        release {
        }
    }
    signingConfigs {
        debug {
        }
    }
}
查看更多
够拽才男人
4楼-- · 2019-06-15 01:09

As described here:

http://tools.android.com/tech-docs/new-build-system/migrating_to_09

The DSL for the library projects is now the same as for the application projects

In particolar you have to put the release block inside the buildTypes.

android {
    buildTypes {
        debug {
        }
        release {
        }
    }
查看更多
登录 后发表回答