2017-06-03 69 views
1

我Android Studio中工作,當我加入的build.gradle文件中的行搖籃DSL方法未找到: '不包括()'

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

我趕上了錯誤:

Gradle DSL method not found: 'exclude()'

錯誤的原因是什麼?

+0

如果你只是在拉一個文件,不要認爲排除可以使用。文件沒有依賴關係 –

+0

@tim_yates,謝謝。也許你是對的。 – Delphian

回答

1

您定義依賴關係的方式是,您將封閉應用於files而不是compile

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

相反,您必須確保直接將關閉應用於compile

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

但我懷疑這是必要的。組和模塊是Maven系統的一部分,JAR文件本身沒有要排除的信息。

+0

謝謝。我試過這種方式,但它不起作用。也許你說得對,JAR文件不能排除信息。但我在互聯網上找到了一些使用這種方案的開發者的例子。我不確定它是否有效。 – Delphian

+0

你想從JAR中排除哪些部分? – tynn

+0

我不能混淆Apache Poi庫(https://stackoverflow.com/questions/44323942/android-proguard-apache-poi-我的問題),我看到推薦排除模塊stax api,就像我上面做的那樣,但我發現了有關DSL方法的錯誤。 – Delphian

相關問題