2

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'
    }
}

I caught the error:

Gradle DSL method not found: 'exclude()'

What is the reason of the error?

Delphian
  • 1,650
  • 3
  • 15
  • 31

1 Answers1

0

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'
}

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'
}

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.

tynn
  • 38,113
  • 8
  • 108
  • 143
  • thank you. I tried this way but it doesn't work. Maybe you are right speaking that JAR file can't exclude the information. But I found some examples in Internet where developers using this scheme. I am not sure that it works. – Delphian Jun 05 '17 at 07:49
  • What parts do you want to exclude from the JAR? – tynn Jun 05 '17 at 08:20
  • I can't obfuscate Apache Poi lib (https://stackoverflow.com/questions/44323942/android-proguard-apache-poi - my question about it) and I saw the recommend to exclude module stax api like I did above, but I caught the error about DSL method. – Delphian Jun 05 '17 at 08:27