After Android Studio update: Gradle DSL method not

2019-01-31 03:06发布

I've just updated my Android Studio and now my project won't build anymore. I get following error:

Error:(16, 0) Gradle DSL method not found: 'runProguard()'
Possible causes:<ul><li>The project 'App' may be using a version of Gradle that does not contain the  method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

I didn't change anything, everything worked properly before the update. Here's my build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.ochs.pipette"
        minSdkVersion 10
        targetSdkVersion 21
        versionCode 8
        versionName "1.6"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.0'
    compile 'it.sephiroth.android.library.imagezoom:library:1.0.4'
    compile 'com.android.support:palette-v7:21.0.+'
}

And here's the other one:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0-rc2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

I don't know how to fix the problem, could anyone help me?

3条回答
对你真心纯属浪费
2楼-- · 2019-01-31 03:39

runProguard has been renamed minifyEnabled. See the changelog here for confirmation - version 0.14.0 (2014/10/31) of the Android Gradle plugin made the swap.

Screenshot showing change location in IDE

查看更多
淡お忘
3楼-- · 2019-01-31 03:45

enter image description hereAs @stkent said, runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.

To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. For example,

buildTypes {
    release {
        runProguard false // Does not exist anymore...
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}

would be replaced by

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

You can see other issues here but this worked for me.

查看更多
劫难
4楼-- · 2019-01-31 03:46

runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) of Gradle.

To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project.

enter image description here

查看更多
登录 后发表回答