Gradle sync failed: Could not find method android() for arguments

Gradle sync failed: Could not find method android() for arguments [build_645ygzrgp6ae4ps0o5libuz2s$_run_closure2@6ddfd772] on root project 'MultiModule'.android

Consult IDE log for more details (Help | Show Log)app

如下是我當時報錯時的 項目 build.gradle 文件內容: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:1.2.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}

android {
    compileSdkVersion 21
    buildToolsVersion '25.0.2'
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 21
    }
    productFlavors {
    }
}
dependencies {
}

緣由:ui

根目錄下的 build.gradle 文件不能包含 android 區塊。spa

android 區塊只能包含在 模塊中的 build.gradle文件中。code

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion '25.0.2'
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 21
    }
}
相關文章
相關標籤/搜索