Java Gradle失败:找到不支持的Gradle DSL方法:';排除();

Java Gradle失败:找到不支持的Gradle DSL方法:';排除();,java,android,google-app-engine,google-cloud-endpoints,Java,Android,Google App Engine,Google Cloud Endpoints,我正试图在我的Android项目(AndroidStudio-latest,Gradle)中包含我最近编写的来自Google Endpoints(Python)的类。服务器端已全部测试并正常工作 我不习惯读Gradle,因此我在下面的文档中。将src下的build.gradle文件(按照文档指示)更改为: build.gradle: buildscript { repositories { mavenCentral() } dependencies {

我正试图在我的Android项目(AndroidStudio-latest,Gradle)中包含我最近编写的来自Google Endpoints(Python)的类。服务器端已全部测试并正常工作

我不习惯读Gradle,因此我在下面的文档中。将src下的build.gradle文件(按照文档指示)更改为:

build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

apply plugin: 'android'

repositories {
    maven {
        url 'http://google-api-client-libraries.appspot.com/mavenrepo'
    }
    mavenCentral()
    mavenLocal()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.2"

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:+'
    compile 'com.google.android.gms:play-services:4.+'

    compile('com.google.api-client:google-api-client:1.17.0-rc') {
        // Exclude artifacts that the Android SDK/Runtime provides.
        exclude('xpp3:xpp3')
        exclude('org.apache.httpcomponents:httpclient')
        exclude('junit:junit')
        exclude('com.google.android:android')
    }

    compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
        // Exclude play services, since we're not using this yet.
        exclude('com.google.android.google-play-services:google-play-services')
    }

    compile('com.google.http-client:google-http-client-android:1.17.0-rc') {
        exclude('com.google.android:android')
    }

    // This is used by the Google HTTP client library.
    compile('com.google.guava:guava:14.0.+')
}
Android Studio返回以下错误:

Gradle 'Project' project refresh failed:
Build script error, unsupported Gradle DSL method found: 'exclude()'!
Possible causes could be:  
- you are using Gradle version where the method is absent 
- you didn't apply Gradle plugin which provides the method
- or there is a mistake in a build script
Build file '/Project/Android/build.gradle' line: 44
: Gradle settings

它不喜欢为依赖项设置
exclude
语句的方式。如果您更仔细地遵循指南中的示例,它应该会起作用

例如,而不是:

compile('com.google.api-client:google-api-client:1.17.0-rc') {
    // Exclude artifacts that the Android SDK/Runtime provides.
    exclude('xpp3:xpp3')
    exclude('org.apache.httpcomponents:httpclient')
    exclude('junit:junit')
    exclude('com.google.android:android')
}
使用以下命令:

compile('com.google.api-client:google-api-client:1.17.0-rc') {
    // Exclude artifacts that the Android SDK/Runtime provides.
    exclude(group: 'xpp3', module: 'xpp3')
    exclude(group: 'org.apache.httpcomponents', module: 'httpclient')
    exclude(group: 'junit', module: 'junit')
    exclude(group: 'com.google.android', module: 'android')
}

可以在初始
编译
坐标中使用压缩格式。

您是否有任何指南可以告诉我如何使用
排除(组:“”,模块:“”)
?请告诉我。我不知道如何准确地使用它。我总是会出错,但是gradle指南没有明确的排除选项。这两种方法对我都不起作用。@Almo,你找到解决方法了吗?我是这样解决的:如果我想排除一个文件怎么办?编译('com.fasterxml.jackson.core:jackson-databind:2.9.0'){exclude“META-INF/LICENSE.txt”}