2014-12-07 34 views
35

Tôi vừa cập nhật Android Studio và bây giờ dự án của tôi sẽ không còn được tạo nữa. Tôi nhận được lỗi sau:Sau khi cập nhật Android Studio: Không tìm thấy phương thức DSL Gradle: '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> 

Tôi không thay đổi bất cứ điều gì, mọi thứ hoạt động bình thường trước khi cập nhật. Dưới đây là build.gradle tập tin của tôi:

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

Và đây là một trong những khác:

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

Tôi không biết làm thế nào để khắc phục vấn đề, bất cứ ai có thể giúp tôi?

Trả lời

68

runProguard đã được đổi tên thành minifyEnabled. Xem the changelog here để xác nhận - phiên bản 0.14.0 (2014/10/31) của plugin Android Gradle đã thực hiện hoán đổi.

Screenshot showing change location in IDE

34

enter image description here Như @stkent nói, runProguard đã được đổi tên thành minifyEnabled trong phiên bản 0.14.0 (2014/10/31) của Gradle.

Để khắc phục điều này, bạn cần thay đổi runProguard thành minifyEnabled trong tệp build.gradle của dự án của bạn. Ví dụ,

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

sẽ được thay thế bởi

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

Bạn có thể thấy các vấn đề khác here nhưng điều này làm việc cho tôi.

+0

Bạn có nghĩa là các tập tin build.gradle đó là trong thư mục ứng dụng, không phải là tập tin build.gradle đó là ở cấp cao nhất của dự án. N'est-ce pas? –

+0

Đó là ý của tôi. Tout à fait! – rousseauo

1

runProguard đã được đổi tên thành minifyEnabled trong phiên bản 0.14.0 (2014/10/31) của Gradle.

Để khắc phục điều này, bạn cần thay đổi runProguard thành minifyEnabled trong tệp build.gradle của dự án của bạn.

enter image description here

Các vấn đề liên quan