Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 未找到Gradle DSL方法:';编译()项目';安卓&x27;可能正在使用不包含该方法的Gradle版本_Android_Android Gradle Plugin_Build.gradle - Fatal编程技术网

Android 未找到Gradle DSL方法:';编译()项目';安卓&x27;可能正在使用不包含该方法的Gradle版本

Android 未找到Gradle DSL方法:';编译()项目';安卓&x27;可能正在使用不包含该方法的Gradle版本,android,android-gradle-plugin,build.gradle,Android,Android Gradle Plugin,Build.gradle,从2-3个小时以来,我一直在研究这个问题。我尝试了许多类似问题的解决方案,但都不起作用。gradle构建工作正常,但在将min sdk级别从23更改为17之后,android studio开始给我这个错误 错误:(32,0)找不到Gradle DSL方法:“compile()”可能原因: 项目“android”可能使用的android Gradle插件版本不包含该方法(例如,在1.1.0中添加了“testCompile”)。 将插件升级至2.3.3版并同步项目 “android”项目可能使用的G

从2-3个小时以来,我一直在研究这个问题。我尝试了许多类似问题的解决方案,但都不起作用。gradle构建工作正常,但在将min sdk级别从23更改为17之后,android studio开始给我这个错误

错误:(32,0)找不到Gradle DSL方法:“compile()”可能原因:

项目“android”可能使用的android Gradle插件版本不包含该方法(例如,在1.1.0中添加了“testCompile”)。 将插件升级至2.3.3版并同步项目

“android”项目可能使用的Gradle版本不包含该方法。 打开Gradle包装文件

生成文件可能缺少Gradle插件。 应用渐变插件

下面是我的gradle文件:

gradle(项目:android)

build.gradle(模块:应用程序)


问题在于依赖项闭包内部:不能在一行中编写多个编译语句。只需将每个编译语句写在单独的一行中,就可以了

我认为,当您为依赖项版本使用变量时,这是一个自动格式化错误,因此将依赖项用双引号而不是单引号括起来。

尝试更改
中的
依赖项。另外,我认为您不需要依赖项中的
classpath
,也可以删除它。
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
        classpath 'com.google.gms:google-services:3.0.0'

    }
}

allprojects {
    repositories {
        mavenLocal()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'
    defaultConfig {
        applicationId "com.google.transporttracker"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        resValue "string", "build_transport_id", (project.findProperty("build_transport_id") ?: "")
        resValue "string", "build_email", (project.findProperty("build_email") ?: "")
        resValue "string", "build_password", (project.findProperty("build_password") ?: "")
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
    productFlavors {
    }
}

ext {
    support = '23.2.0'
    playServices = '10.2.4'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile "com.android.support:appcompat-v7:$support" compile "com.android.support:cardview-v7:$support" compile "com.android.support:design:$support" compile "com.google.android.gms:play-services-gcm:$playServices" compile "com.google.android.gms:play-services-location:$playServices" compile "com.google.firebase:firebase-core:$playServices" compile "com.google.firebase:firebase-auth:$playServices" compile "com.google.firebase:firebase-config:$playServices" compile "com.google.firebase:firebase-crash:$playServices" compile "com.google.firebase:firebase-database:$playServices" compile 'com.android.support.constraint:constraint-layout:1.0.2'
    classpath 'com.google.gms:google-services:3.0.0'
    compile 'com.google.android.gms:play-services-maps:10.2.4'
    compile 'com.android.support:appcompat-v7:23.4.0'
    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'