简体   繁体   English

找不到Gradle DSL方法android()

[英]Gradle DSL method not found android()

I open a friend project at Android Studio, my AS version is greater than his. 我在Android Studio中打开一个朋友项目,我的AS版本大于他的版本。

Here is the error: 这是错误:

Error:(27, 0) Gradle DSL method not found: 'android()'
Possible causes:The project 'firstapp' 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.

Here is the build.gradle: 这是build.gradle:

// 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.2.0-alpha1'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

android {
    compileSdkVersion 19
    buildToolsVersion '21.0.0'
}
dependencies {
}

How can i get this fixed? 我该如何解决此问题?

Look here from official doc. 从官方文档看这里。 https://developer.android.com/studio/build/index.html https://developer.android.com/studio/build/index.html

/**
 * The first line in the build configuration applies the Android plugin for
 * Gradle to this build and makes the android {} block available to specify
 * Android-specific build options.
 */

apply plugin: 'com.android.application'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM