Gradle DSL method not found: 'runProguard()'

本来刚升级studio到1.0的时候就想写这篇文章的,但是没空就没写了。

好吧,今天把这个问题写下,因为很多同事也遇到这个问题,解决不了,在你把Android studio升级到1.0后,你会发现你的gradle sync的时候会报底下这个错:


报这个错的原因其实是因为你在升级完后,然后工程会默认把你的gradle版本替换成最新的版本,所以你的build.gradle文件中的dependencies也变成最新的了,如下:

    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0-rc1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

那为啥变成最新的就不行了,其实这个我觉得是gradle团队可能不是那么强大的原因吧,新版本可能没有做到向下兼容旧版本...其实看报错就知道了,runProguard()找不着了。以前也有出现过0.12到0.14后 "useOldManifestMerger“找不到的问题。

要让sync成功,改下gradle的版本就可以了,如下:

dependencies {
        classpath 'com.android.tools.build:gradle:0.14.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }


PS,感谢ohskean的提醒,我这边也将他提供的方法加到文章来,

old:

buildTypes {
    release {

        runProguard false // 已经被废弃并且停止使用了

        ......
    }
}

new:

buildTypes {
    release {

        minifyEnabled false // 替代的方式

        ......
    }
}

猜你喜欢

转载自blog.csdn.net/hyr83960944/article/details/41644195