android - 错误 :(26, 0) 未找到 Gradle DSL 方法: 'runProguard()'

标签 android android-gradle-plugin

我正在使用带有 gradle 的 android studio 0.9.3 'com.android.tools.build:gradle:0.14.+'

应用插件:'com.android.application'

android {
    compileSdkVersion 19
    buildToolsVersion '20.0.0'

    defaultConfig {
        applicationId "xxx.xxx.xxx"
        minSdkVersion 16
        targetSdkVersion 19
        versionCode 1
        versionName "1.0.11"
    }

    signingConfigs{
        releaseConfig{
            storeFile file("xxxxxxx")
            storePassword = "xxxx"
            keyAlias = "xxxx"
            keyPassword = "xxxx"
        }
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.releaseConfig

            // adds version to file name
            applicationVariants.all { variant ->
                def file = variant.outputFile
                variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    // You must install or update the Google Repository through the SDK manager to use this dependency.
    // You must install or update the Support Repository through the SDK manager to use this dependency.
    compile 'com.android.support:support-v4:19.+'
    compile 'com.android.support:appcompat-v7:19.+'
    compile 'com.mcxiaoke.volley:library:1.0.6'
    compile 'com.google.code.gson:gson:2.2.+'
}

之前编译的项目没有对该文件进行任何更改, 我越来越: 错误:(26, 0) Gradle DSL 方法未找到:'runProguard()'

如何解决?

最佳答案

不要在 gradle 文件中使用 runProguard,而是尝试使用 minifyEnabled。这应该可以解决问题。 runProguard 已弃用,很快就会停止工作。

编辑

要使用 minifyEnabled,gradle 应该更新到 2.2 或更高版本。

关于android - 错误 :(26, 0) 未找到 Gradle DSL 方法: 'runProguard()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27016385/

相关文章:

android - 如何在 Android 单元测试中打开控制台输出?

javascript - 隐藏从 SD 卡库下载的文件 - PhoneGap

java - 反序列化期间出现奇怪的异常

c# - 如何获取 Mono Xamarin Android 应用程序路径文件夹?

android - 没有与请求的版本匹配的 NDK 版本

android - 如何使用最新的 R8 Shrinker 版本

java - 以编程方式发送短信 - 设置过期时间

Android:外部SD卡的绝对位置

Android studio(2.1.1 April 28-2016) 将字节码转换为 dex 时出现奇怪的错误。 Dex 无法解析版本 52 字节代码

android - Android Studio 3.0:无法合并DEX