2014-12-07 70 views
35

我剛剛更新了我的Android Studio,現在我的項目不再生成。我得到以下錯誤:Android Studio更新後:未找到Gradle DSL方法:'runProguard()'

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

我不知道如何解決這個問題,任何人都可以幫助我嗎?

回答

68

runProguard已更名爲minifyEnabled。請參閱the changelog here進行確認 - Android Gradle插件的版本0.14.0(2014/10/31)進行了交換。

Screenshot showing change location in IDE

34

enter image description here作爲@stkent說,runProguard已更名爲minifyEnabled在搖籃的版本0.14.0(2014年10月31日)。

要解決這個問題,你需要在的build.gradle文件項目的改變runProguardminifyEnabled。例如,

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

代替你可以看到其他的問題here但是這爲我工作。

+0

你的意思是的build.gradle文件是在app文件夾,而不是文件的build.gradle是在項目的頂級水平。 N'est-ce pas? – 2015-06-03 19:58:48

+0

這就是我的意思。 Toutàfait! – rousseauo 2015-06-04 23:11:48

1

runProguard已更名爲minifyEnabled在搖籃的版本0.14.0(2014年10月31日)。

要解決此問題,您需要將runProguard更改爲項目的build.gradle文件中的minifyEnabled。

enter image description here

相關問題