Android Studio更新后:未找到Gradle DSL方法:'runProguard()'

use*_*644 35 android android-gradle-plugin

我刚刚更新了我的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>
Run Code Online (Sandbox Code Playgroud)

我没有改变任何东西,在更新之前一切正常.这是我的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.+'
}
Run Code Online (Sandbox Code Playgroud)

这是另一个:

// 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()
    }
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决问题,任何人都可以帮助我吗?

stk*_*ent 68

runProguard已重命名minifyEnabled.请参阅此处的更改日志以进行确认 - 版本0.14.0(2014/10/31)的Android Gradle插件进行了交换.

屏幕截图显示IDE中的更改位置


rou*_*auo 34

在此输入图像描述正如@stkent所说,runProguard已经重命名为minifyEnabledGradle的0.14.0版(2014/10/31).

为了解决这个问题,您需要更改runProguardminifyEnabled的build.gradle项目的文件.例如,

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

将被替换为

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
Run Code Online (Sandbox Code Playgroud)

你可以在这里看到其他问题,但这对我有用.