找不到Gradle DSL方法:'runProguard'

本文翻译自:Gradle DSL method not found: 'runProguard'

I get an error after updating from my last project. 从我上一个项目更新后出现错误。 Not a problem in my code but I'm having trouble with build.gradle. 我的代码不是问题,但我在build.gradle时遇到问题。 How can I fix it? 我该如何解决?

build.gradle code here: build.gradle代码在这里:

apply plugin: 'android'

android {
    compileSdkVersion 21
    buildToolsVersion '20.0.0'

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }

    defaultConfig {
        applicationId 'com.xxx.axxx'
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 6
        versionName '1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.+'
    compile files('libs/commons-codec-1.8.jar')
    compile files('libs/asmack-android-8-4.0.4.jar')
    compile 'com.android.support:support-v4:21.0.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.jakewharton:butterknife:5.1.1'
}

Gradle Sync message output: Gradle Sync消息输出:

Error:(27, 0) Gradle DSL method not found: 'runProguard()'
**Possible causes:
The project 'Atomic4Mobile' may be using a version of Gradle that does not contain the method.
**Gradle settings**
The build file may be missing a Gradle plugin.
**Apply Gradle plugin**

#1楼

参考:https://stackoom.com/question/1pcF9/找不到Gradle-DSL方法-runProguard


#2楼

在此输入图像描述 If you are using version 0.14.0 or higher of the gradle plugin, you should replace "runProguard" with "minifyEnabled" in your build.gradle files. 如果您使用的是gradle插件的0.14.0或更高版本,则应在build.gradle文件中将“ runProguard”替换为“minifyEnabled”

runProguard was renamed to minifyEnabled in version 0.14.0. runProguard更名为minifyEnabled在0.14.0版本。 For more info, See Android Build System 有关更多信息, 请参阅Android Build System


#3楼

Using 'minifyEnabled' instead of 'runProguard' works properly. 使用'minifyEnabled'而不是'runProguard'可以正常工作。

Previous code:

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

Current code:

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

Hope this helps. 希望这可以帮助。


#4楼

If you are migrating to 1.0.0 you need to change the following properties. 如果要迁移到1.0.0,则需要更改以下属性。

In the Project's build.gradle file you need to replace minifyEnabled. 在Project的build.gradle文件中,您需要替换minifyEnabled。

Hence your new build type should be 因此,您的新构建类型应该是

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

Also make sure that gradle version is 1.0.0 like 还要确保gradle版本是1.0.0之类的

classpath 'com.android.tools.build:gradle:1.0.0'

in the build.gradle file. build.gradle文件中。

This should solve the problem. 这应该可以解决问题。

Source: http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0 资料来源: http//tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0


#5楼

By changing runProguard to minifyEnabled , part of the issue gets fixed. 通过将runProguard更改为minifyEnabled ,可以解决部分问题。

But the fix can cause "Library Projects cannot set application Id" (you can find the fix for this here Android Studio 1.0 and error "Library projects cannot set applicationId" ). 但修复可能导致“库项目无法设置应用程序ID”(您可以在此处找到Android Studio 1.0的修复程序, 并且错误“库项目无法设置applicationId” )。

By removing application Id in the build.gradle file, you should be good to go. 通过删除build.gradle文件中的应用程序ID,您应该很高兴。


#6楼

runProguard has been renamed to minifyEnabled in version 0.14.0 (2014/10/31) or more in Gradle. runProguard已在Gradle版本0.14.0(2014/10/31)或更高版本中重命名为minifyEnabled

To fix this, you need to change runProguard to minifyEnabled in the build.gradle file of your project. 要解决此问题,您需要在项目的build.gradle文件中将runProguard更改为minifyEnabled。

在此输入图像描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值