Error:(22, 0) Could not find method android() for arguments
开发中,新从远程仓库或者新建项目有时会出现这个错误提示:
Error:(22, 0) Could not find method android() for arguments
[build_9wglzemmdwpqh4v6gkig07116$_run_closure3@565f363a] on root project 'MyApplicationTest' of type org.gradle.api.Project.
错误原因:
开发工具的自身的bug,在自动帮我们生成一些代码时,生成错了地方。其中这Error:(22,0),表示这是一个错误,且错误出现在22行,第0列处。点击open file,可以快速直达该出错位置。
解决方案:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
}
dependencies {
}
从上面找到该部分,并把上面的这部分删除即可。如下:
android {
compileSdkVersion 'Google Inc.:Google APIs:17'
}