贴出在studio导入项目出现的错误问题。
Error:(13, 0) Gradle DSL method not found: ‘android()’
Possible causes:
- The project ‘ScanDemo’ may be using a version of the Android Gradle plug-in that does not contain the method (e.g. ‘testCompile’ was added in 1.1.0).
Fix plugin version and sync project - The project ‘ScanDemo’ may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file - The build file may be missing a Gradle plugin.
Apply Gradle plugin - 图片如下:
这个问题是因为,我们导入项目,studio会检查导入的项目的版本是否本地存在这个版本,如果不存在,一般会提示错误:
一般解决版本去下载这个版本,可以解决!
但也一种情况是studio在导入项目的时候,如果不存在版本,会在整个项目(最外层的)build.gradle加上android {
compileSdkVersion 21
buildToolsVersion “21.0.0”
},
也有可能导入版本不存在这边版本,你手动去修改app下对应的SDK版本,这种情况也会出现Gradle DSL method not found: ‘android();
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.0.0"
}
解决方案是:删除最外层build.gradle的
android {
compileSdkVersion 21
buildToolsVersion “21.0.0”
}
重新编译就可以了,希望能帮助到您!