Gradle DSL method not found: 'android()'
原文代码
Error:(12, 0) Gradle DSL method not found: 'android()'
Possible causes:<ul><li>The project 'xxxx' 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).
<a href="fixGradleElements">Fix plugin version and sync project</a></li><li>The project 'paydemo' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
错误原因:
android studio 引进项目时,自动查找本机是否有项目设置的SDK版本,若发现没有,我们会在project structure修改成自己的SDK。然而,修改后,AS会自动在项目下的build.gradle里添加上以下代码:
解决办法:
删除以上图片中红框中的代码,然后再执行build->Rebuild project,删除完之后的代码如下:
Plugin with id 'com.android.application' not found.
原文错误提示
Error:(1, 0) Plugin with id 'com.android.application' not found.
<a href="openFile:E:\Android_studio_code\work\paydemo\app\build.gradle">Open File</a>
buildscript {
。。。。。。。。
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
加上 dependencies