1.android()方法找不到
Just remove the following code from build.gradle file
build.gradle
android {
compileSdkVersion ‘android-MNC’
buildToolsVersion ‘xx.x.x’
}
dependencies {
}
2.runProguard()找不到
在新版本的gradle中,runProguard这个方法已经废弃了,并且改为新的方法 minifyEnabled. 因此,正确的解决方法不是修改gradle的版本号,而是将项目中每个Module对应的build.gradle文件中的runProguard方法名改为 minifyEnabled
3.can’t find default.
删除library,重新添加
4.之前在使用一个mvp框架mosby时报了这样的问题Error:(9, 0) Gradle DSL method not found: ‘compile()’,这是我在build.gradle中加了两行依赖之后,在sync的时候出现了这样的问题
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
compile 'com.hannesdorfmann.mosby3:mvp:3.0.4' // Plain MVP
compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4' // MVP + ViewState support
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
后来google了一下,在这个回答里找到了答案
https://stackoverflow.com/questions/27617687/gradle-dsl-method-not-found-compile
但是回答里提到的两个build.gradle有什么区别呢,下图可以看到两个build.gradle,一个在整个工程目录下,一个在app目录下
其中一个用于整个项目,另一个用于app应用模块。应用于整个项目的内容很少,没啥好解释的,内容保持默认不变就行了。我们要了解和经常编辑的是app/build.gradle文件
5.