这个问题困扰了我很长时间,好吧,搜了半天全都是runProguard的,最后在stackoverflow上搜到解决办法了:
http://stackoverflow.com/questions/27735646/android-studio-gradle-dsl-method-not-found-android-error17-0
解决方法:
删掉最外层的build.gradle中的
android {
compileSdkVersion 22 buildToolsVersion "20.0.0"
}
然后重新刷新就ok了
2.解决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:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">buildTypes </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> release </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> <span style="color: rgb(255, 0, 0);">runProguard </span></span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"><span style="color: rgb(255, 0, 0);">false</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="com" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; color: rgb(128, 128, 128); background-color: transparent; background-position: initial initial; background-repeat: initial initial;">// 已经被废弃并且停止使用了</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> ......</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">}</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">}</span></code>
new:
<code style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; white-space: inherit;"><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">buildTypes </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> release </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">{</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> <span style="color: rgb(255, 0, 0);">minifyEnabled </span></span><span class="kwd" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"><span style="color: rgb(255, 0, 0);">false</span></span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="com" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; color: rgb(128, 128, 128); background-color: transparent; background-position: initial initial; background-repeat: initial initial;">// 替代的方式</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> ......</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">}</span><span class="pln" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;"> </span><span class="pun" style="margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; background-color: transparent; background-position: initial initial; background-repeat: initial initial;">}</span></code>