找不到Gradle DSL方法:' exclude()' [英] Gradle DSL method not found: 'exclude()'

查看:116
本文介绍了找不到Gradle DSL方法:' exclude()'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android Studio中工作,当我在build.gradle文件中添加该行时

I am working in Android Studio and when I added the line in build.gradle file

dependencies {
    compile files('libs/poi-ooxml-schemas-3.12-20150511-a.jar'){
        exclude group: 'stax', module: 'stax-api'
    }
}

我发现了错误:

找不到等级DSL方法:'exclude()'

Gradle DSL method not found: 'exclude()'

错误原因是什么?

推荐答案

定义依赖项的方式是将闭包应用于文件,而不是 compile .

The way you defined the dependency, you applied the closure to files instead of compile.

files('libs/poi-ooxml-schemas-3.12-20150511-a.jar'){
    exclude group: 'stax', module: 'stax-api'
}

相反,您必须确保将闭包直接应用于 compile .

Instead you have to make sure to apply the closure to compile directly.

compile(files('libs/poi-ooxml-schemas-3.12-20150511-a.jar')){
    exclude group: 'stax', module: 'stax-api'
}

但是我怀疑这根本没有必要.组和模块是Maven系统的一部分,并且JAR文件本身没有要排除的信息.

But I doubt it's necessary at all. Groups and modules are part of the Maven system and the JAR file itself doesn't have this information to exclude.

这篇关于找不到Gradle DSL方法:' exclude()'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆