安卓工作室更新后:Gradle DSL方法未找到:'runProguard()'

35

我刚刚更新了我的Android Studio,现在我的项目无法再次构建。 我收到以下错误:

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>

升级前一切正常,我什么也没改。这是我的build.gradle文件:

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.+'
}

这是另一个:

// 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()
    }
}

我不知道如何解决这个问题,有人可以帮忙吗?

3个回答

68

runProguard已更名为minifyEnabled。请查看此处的更新日志以确认-Android Gradle插件的版本0.14.0(2014/10/31)进行了更改。

显示IDE中更改位置的截图


34

enter image description here正如 @stkent 所说,在 Gradle 版本 0.14.0(2014/10/31)中,runProguard 已更名为 minifyEnabled

要解决此问题,您需要在项目的 build.gradle 文件中将 runProguard 更改为 minifyEnabled。例如:

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

将被替换为

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
您可以在此处查看其他问题。但这对我有效。

你是指位于app文件夹中的build.gradle文件,而不是位于项目顶层的build.gradle文件,对吗? - Ray Kiddy
这就是我想表达的意思。完全正确! - rousseauo

1

runProguard在Gradle的版本0.14.0(2014/10/31)中已更名为minifyEnabled

要解决此问题,您需要在项目的build.gradle文件中将runProguard更改为minifyEnabled。

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接